diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-03-15 08:51:42 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2009-03-15 08:51:42 +0000 |
commit | 44d5b22097bb2dac6a514db3de5555d115593e7f (patch) | |
tree | c7107d9a32e0d0c7bcbcb877e1c0993829e2f8c5 /pspax.c | |
parent | c&p error (diff) | |
download | pax-utils-44d5b22097bb2dac6a514db3de5555d115593e7f.tar.gz pax-utils-44d5b22097bb2dac6a514db3de5555d115593e7f.tar.bz2 pax-utils-44d5b22097bb2dac6a514db3de5555d115593e7f.zip |
check return values of fscanf() and chdir() since gcc whines about it now
Diffstat (limited to 'pspax.c')
-rw-r--r-- | pspax.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -12,7 +12,7 @@ * cc -o pspax pspax.c -DWANT_SYSCAP -lcap */ -static const char *rcsid = "$Id: pspax.c,v 1.43 2008/12/30 13:50:04 vapier Exp $"; +static const char *rcsid = "$Id: pspax.c,v 1.44 2009/03/15 08:51:42 vapier Exp $"; const char * const argv0 = "pspax"; #include "paxinc.h" @@ -54,10 +54,15 @@ static char *get_proc_name(pid_t pid) FILE *fp; static char str[BUFSIZ]; - if ((fp = proc_fopen(pid, "stat")) == NULL) + fp = proc_fopen(pid, "stat"); + if (fp == NULL) return NULL; - fscanf(fp, "%*d %s.16", str); + if (fscanf(fp, "%*d %s.16", str) != 1) { + fclose(fp); + return NULL; + } + if (*str) { str[strlen(str) - 1] = '\0'; str[16] = 0; @@ -300,11 +305,9 @@ static void pspax(const char *find_name) caps = NULL; - chdir(PROC_DIR); - if (!(dir = opendir(PROC_DIR))) { - perror(PROC_DIR); - exit(EXIT_FAILURE); - } + dir = opendir(PROC_DIR); + if (dir == NULL || chdir(PROC_DIR)) + errp(PROC_DIR); if (access("/proc/self/attr/current", R_OK) != -1) have_attr = 1; |