summaryrefslogtreecommitdiff
path: root/lib-src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-01-22 23:30:19 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2011-01-22 23:30:19 -0800
commit9055082ef8a2f1b9033f77f0eb2b9c756a306c01 (patch)
tree041665ff66c2bdab89f2f59976fb9ce0e2003ab0 /lib-src
parentf77fabaf6bc1296631b1a4bcdf363721e19a3ac4 (diff)
downloademacs-9055082ef8a2f1b9033f77f0eb2b9c756a306c01.tar.gz
Check return values of some library calls.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/ChangeLog8
-rw-r--r--lib-src/hexl.c8
-rw-r--r--lib-src/make-docfile.c13
-rw-r--r--lib-src/movemail.c3
4 files changed, 26 insertions, 6 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index 232bb389fd7..74509f4ae5e 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,11 @@
+2011-01-23 Paul Eggert <eggert@cs.ucla.edu>
+
+ Check return values of some library calls.
+ * hexl.c (main): Check fread result.
+ * make-docfile.c (main): Check chdir result.
+ (scan_c_file): Check fscanf result.
+ * movemail.c (main): Check ftruncate result.
+
2011-01-17 Paul Eggert <eggert@cs.ucla.edu>
Include <unistd.h> unilaterally.
diff --git a/lib-src/hexl.c b/lib-src/hexl.c
index aa5b370aade..e0a5166760a 100644
--- a/lib-src/hexl.c
+++ b/lib-src/hexl.c
@@ -179,7 +179,9 @@ main (int argc, char **argv)
#define hexchar(x) (isdigit (x) ? x - '0' : x - 'a' + 10)
- fread (buf, 1, 10, fp); /* skip 10 bytes */
+ /* Skip 10 bytes. */
+ if (fread (buf, 1, 10, fp) != 10)
+ break;
for (i=0; i < 16; ++i)
{
@@ -207,7 +209,9 @@ main (int argc, char **argv)
if (i < 16)
break;
- fread (buf, 1, 18, fp); /* skip 18 bytes */
+ /* Skip 18 bytes. */
+ if (fread (buf, 1, 18, fp) != 18)
+ break;
}
}
}
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c
index 4260e4c08f6..b6fccfacfec 100644
--- a/lib-src/make-docfile.c
+++ b/lib-src/make-docfile.c
@@ -158,7 +158,11 @@ main (int argc, char **argv)
}
if (argc > i + 1 && !strcmp (argv[i], "-d"))
{
- chdir (argv[i + 1]);
+ if (chdir (argv[i + 1]) != 0)
+ {
+ perror (argv[i + 1]);
+ return EXIT_FAILURE;
+ }
i += 2;
}
@@ -648,6 +652,7 @@ scan_c_file (char *filename, const char *mode)
if (defunflag && (commas == 1 || commas == 2))
{
+ int scanned = 0;
do
c = getc (infile);
while (c == ' ' || c == '\n' || c == '\r' || c == '\t');
@@ -655,12 +660,14 @@ scan_c_file (char *filename, const char *mode)
goto eof;
ungetc (c, infile);
if (commas == 2) /* pick up minargs */
- fscanf (infile, "%d", &minargs);
+ scanned = fscanf (infile, "%d", &minargs);
else /* pick up maxargs */
if (c == 'M' || c == 'U') /* MANY || UNEVALLED */
maxargs = -1;
else
- fscanf (infile, "%d", &maxargs);
+ scanned = fscanf (infile, "%d", &maxargs);
+ if (scanned < 0)
+ goto eof;
}
}
diff --git a/lib-src/movemail.c b/lib-src/movemail.c
index b127c85951d..f492188963d 100644
--- a/lib-src/movemail.c
+++ b/lib-src/movemail.c
@@ -488,7 +488,8 @@ main (int argc, char **argv)
#ifdef MAIL_USE_SYSTEM_LOCK
if (! preserve_mail)
{
- ftruncate (indesc, 0L);
+ if (ftruncate (indesc, 0L) != 0)
+ pfatal_with_name (inname);
}
#endif /* MAIL_USE_SYSTEM_LOCK */