Date: Mon, 17 Jul 2000 00:17:07 -0700 (PDT) From: chucha@jam.tario.ru To: freebsd-gnats-submit@FreeBSD.org Subject: misc/19975: fgets() and fread() on file without reading rights leads to SEGV Message-ID: <20000717071707.2053837B930@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 19975
>Category: misc
>Synopsis: fgets() and fread() on file without reading rights leads to SEGV
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Mon Jul 17 00:20:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: Pavel Chuchkalov
>Release: 3.0 and 3.2 ugraded to 4.0
>Organization:
-
>Environment:
FreeBSD 4.0-RELEASE i386
>Description:
If in program file is open, and this file does not have rights to read, fgets() and fread() will cause segmentation violation. fgets() and fread() on "failed" FILE* returned by fopen() crashes program also (use the source code below but do not 'touch test') - stupid but possible programmer's error. I don't know about read() call and others.
>How-To-Repeat:
#include <stdio.h>
extern int errno;
main() {
FILE *file;
char str[1024];
file = fopen("test", "r");
// fgets(str, sizeof(str), file);
// fread(str, sizeof(str), 1, file);
printf("feof(file) = %d, errno = %d, ferror(file) = %d\n",
feof(file), errno, ferror(file));
}
>Fix:
I'm not competent in fixing, but I would like to be :) Please, CC: chucha@jam.tario.ru while discussing this problem, or tell me maillist (oh, how I'm tired of all of them! ;) where this problem will be discussed. Or, if I'm really wrong and my trouble is only in my mind, let me know also... Good luck!
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000717071707.2053837B930>
