aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2007-10-15 02:00:56 +0000
committerAlan Modra <amodra@gmail.com>2007-10-15 02:00:56 +0000
commit615f314969111779bdaffaef0e00d13a0efd51f5 (patch)
tree234eaa69ef30f097b5316983ade490b64de93841 /binutils
parent5375ec41bea0ede4ebb4ef8afdc5df82466b3db9 (diff)
downloadgdb-615f314969111779bdaffaef0e00d13a0efd51f5.zip
gdb-615f314969111779bdaffaef0e00d13a0efd51f5.tar.gz
gdb-615f314969111779bdaffaef0e00d13a0efd51f5.tar.bz2
* 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.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog7
-rw-r--r--binutils/objdump.c9
-rw-r--r--binutils/srconv.c14
-rw-r--r--binutils/sysdump.c13
4 files changed, 34 insertions, 9 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index add3ffc..f7b628b 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -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
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 03bc4d6..ee5530b 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -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. */
diff --git a/binutils/srconv.c b/binutils/srconv.c
index 914c260..2a7d638 100644
--- a/binutils/srconv.c
+++ b/binutils/srconv.c
@@ -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
diff --git a/binutils/sysdump.c b/binutils/sysdump.c
index 6b3fbda..8387e71 100644
--- a/binutils/sysdump.c
+++ b/binutils/sysdump.c
@@ -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