Attached is a patch to try. Pat ---
[PATCH xditview] Make sure filename is a regular file. If filename is not '-' or '|' make sure it is a regular file. Signed-off-by: Patrick E. Kane <[email protected]> --- xditview.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/xditview.c b/xditview.c index 99fd240..dbb183b 100644 --- a/xditview.c +++ b/xditview.c @@ -59,6 +59,7 @@ from the X Consortium. #include "xdit_mask.bm" #include <stdio.h> #include <stdlib.h> +#include <sys/stat.h> /* Command line options table. Only resources are entered here...there is a pass over the remaining options after XtParseCommand is let loose. */ @@ -395,6 +396,19 @@ VisitFile (char *name, Boolean resetPage) else if (name[0] == '|') new_file = popen (name+1, "r"); else { + struct stat stbuf; + /* + * Make sure it is a regular file + */ + if (stat(name, &stbuf) != 0) { + perror(name); + return; + } + if (! S_ISREG(stbuf.st_mode)){ + fprintf(stderr, "%s is not a regular file\n", name); + return; + } + new_file = fopen (name, "r"); seek = 1; } -- 1.7.1.1 2010/12/6 Krzysztof Żelechowski <[email protected]>: > Dnia poniedziałek, 6 grudnia 2010 o 14:47:02 Pat Kane napisał(a): >> Strace shows that "xditview ." does: >> open(".", O_RDONLY) = 4 >> followed by an infinite number of: >> read(4, 0xb7576000, 4096) = -1 EISDIR (Is a directory) >> >> Looks broken. >> > > Looks like the programmer forgot to examine the return value. Probably the > most common bug in C. > > Chris >
[PATCH xditview] Make sure filename is a regular file. If filename is not '-' or '|' make sure it is a regular file. Signed-off-by: Patrick E. Kane <[email protected]> --- xditview.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/xditview.c b/xditview.c index 99fd240..dbb183b 100644 --- a/xditview.c +++ b/xditview.c @@ -59,6 +59,7 @@ from the X Consortium. #include "xdit_mask.bm" #include <stdio.h> #include <stdlib.h> +#include <sys/stat.h> /* Command line options table. Only resources are entered here...there is a pass over the remaining options after XtParseCommand is let loose. */ @@ -395,6 +396,19 @@ VisitFile (char *name, Boolean resetPage) else if (name[0] == '|') new_file = popen (name+1, "r"); else { + struct stat stbuf; + /* + * Make sure it is a regular file + */ + if (stat(name, &stbuf) != 0) { + perror(name); + return; + } + if (! S_ISREG(stbuf.st_mode)){ + fprintf(stderr, "%s is not a regular file\n", name); + return; + } + new_file = fopen (name, "r"); seek = 1; } -- 1.7.1.1
_______________________________________________ [email protected]: X.Org support Archives: http://lists.freedesktop.org/archives/xorg Info: http://lists.freedesktop.org/mailman/listinfo/xorg Your subscription address: [email protected]
