* objdump.c (print_line): Check fwrite return value.
authorAlan Modra <amodra@gmail.com>
Mon, 15 Oct 2007 02:00:56 +0000 (02:00 +0000)
committerAlan Modra <amodra@gmail.com>
Mon, 15 Oct 2007 02:00:56 +0000 (02:00 +0000)
* srconv.c (checksum, wr_tr, wr_cs): Likewise.
* sysdump.c (fillup): Return zero on getc or fread EOF.  Return count
read.

binutils/ChangeLog
binutils/objdump.c
binutils/srconv.c
binutils/sysdump.c

index add3ffc57fb30ccac99f7c0ab8ee5b4b6c385136..f7b628b4c46956d253be094f72598c07b0e3e926 100644 (file)
@@ -1,3 +1,10 @@
+2007-10-15  Alan Modra  <amodra@bigpond.net.au>
+
+       * objdump.c (print_line): Check fwrite return value.
+       * srconv.c (checksum, wr_tr, wr_cs): Likewise.
+       * sysdump.c (fillup): Return zero on getc or fread EOF.  Return count
+       read.
+
 2007-10-10  Jim Blandy  <jimb@codesourcery.com>
 
        * dwarf.c (process_debug_info): Line up section offsets of
index 03bc4d60ae12a887bb202ffd461f41bd0fd87b9e..ee5530b1464f3131ff53914803160d90f6ca7847 100644 (file)
@@ -1130,14 +1130,17 @@ static void
 print_line (struct print_file_list *p, unsigned int line)
 {
   const char *l;
+  size_t len;
  
   --line; 
   if (line >= p->maxline)
     return;
   l = p->linemap [line];
-  fwrite (l, 1, strcspn (l, "\n\r"), stdout);
-  putchar ('\n');
-} 
+  /* Test fwrite return value to quiet glibc warning.  */
+  len = strcspn (l, "\n\r");
+  if (len == 0 || fwrite (l, len, 1, stdout) == 1)
+    putchar ('\n');
+}
 
 /* Print a range of source code lines. */
 
index 914c26071685f094df8d7f97a0a89c1bae6d126b..2a7d63876a31e286887818a45e3efa5ca8a1f175 100644 (file)
@@ -176,7 +176,9 @@ checksum (FILE *file, unsigned char *ptr, int size, int code)
 
   /* Glue on a checksum too.  */
   ptr[bytes] = ~sum;
-  fwrite (ptr, bytes + 1, 1, file);
+  if (fwrite (ptr, bytes + 1, 1, file) != 1)
+    /* FIXME: Return error status.  */
+    abort ();
 }
 
 
@@ -299,7 +301,10 @@ wr_tr (void)
       0x03,                    /* RL */
       0xfd,                    /* CS */
     };
-  fwrite (b, 1, sizeof (b), file);
+
+  if (fwrite (b, sizeof (b), 1, file) != 1)
+    /* FIXME: Return error status.  */
+    abort ();
 }
 
 static void
@@ -1452,7 +1457,10 @@ wr_cs (void)
     0x00,                      /* dot */
     0xDE                       /* CS */
   };
-  fwrite (b, 1, sizeof (b), file);
+
+  if (fwrite (b, sizeof (b), 1, file) != 1)
+    /* FIXME: Return error status.  */
+    abort ();
 }
 
 /* Write out the SC records for a unit.  Create an SC
index 6b3fbdaec04f071226ff26c97925fbabcf2b7ef1..8387e711f836d7fe2236896d496e7578d12ab260 100644 (file)
@@ -119,8 +119,15 @@ fillup (unsigned char *ptr)
   int sum;
   int i;
 
-  size = getc (file) - 2;
-  fread (ptr, 1, size, file);
+  size = getc (file);
+  if (size == EOF
+      || size <= 2)
+    return 0;
+
+  size -= 2;
+  if (fread (ptr, size, 1, file) != 1)
+    return 0;
+
   sum = code + size + 2;
 
   for (i = 0; i < size; i++)
@@ -132,7 +139,7 @@ fillup (unsigned char *ptr)
   if (dump)
     dh (ptr, size);
 
-  return size - 1;
+  return size;
 }
 
 static barray
This page took 0.033595 seconds and 4 git commands to generate.