diff options
author | Ian Lance Taylor <ian@airs.com> | 1994-04-04 22:49:04 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1994-04-04 22:49:04 +0000 |
commit | 4002f18a05ecf53961c0e3b25a6d835576239fab (patch) | |
tree | f1418405276000a7a2eec3c0c95722c53bb9ca96 | |
parent | 6d4f771502a396883f5e201165512effd6c808b6 (diff) | |
download | gdb-4002f18a05ecf53961c0e3b25a6d835576239fab.zip gdb-4002f18a05ecf53961c0e3b25a6d835576239fab.tar.gz gdb-4002f18a05ecf53961c0e3b25a6d835576239fab.tar.bz2 |
Made sure that every call to bfd_read, bfd_write, and bfd_seek
checks the return value and handled bfd_error correctly. These
changes are not itemised.
-rw-r--r-- | bfd/ChangeLog | 36 | ||||
-rw-r--r-- | bfd/aout-adobe.c | 31 | ||||
-rw-r--r-- | bfd/aout-encap.c | 3 | ||||
-rw-r--r-- | bfd/aout-target.h | 3 | ||||
-rw-r--r-- | bfd/aoutf1.h | 29 | ||||
-rw-r--r-- | bfd/archive.c | 110 | ||||
-rw-r--r-- | bfd/bout.c | 23 | ||||
-rw-r--r-- | bfd/cisco-core.c | 8 | ||||
-rw-r--r-- | bfd/coff-rs6000.c | 9 | ||||
-rw-r--r-- | bfd/ecoff.c | 9 | ||||
-rw-r--r-- | bfd/elfcode.h | 45 | ||||
-rw-r--r-- | bfd/hp300hpux.c | 21 | ||||
-rw-r--r-- | bfd/hppabsd-core.c | 3 | ||||
-rw-r--r-- | bfd/hpux-core.c | 8 | ||||
-rw-r--r-- | bfd/i386lynx.c | 24 | ||||
-rw-r--r-- | bfd/ieee.c | 86 | ||||
-rw-r--r-- | bfd/irix-core.c | 12 | ||||
-rw-r--r-- | bfd/libaout.h | 24 | ||||
-rw-r--r-- | bfd/libbfd.c | 3 | ||||
-rw-r--r-- | bfd/nlm32-ppc.c | 30 | ||||
-rw-r--r-- | bfd/nlmcode.h | 257 | ||||
-rw-r--r-- | bfd/tekhex.c | 24 |
22 files changed, 429 insertions, 369 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 50837ec..9350dc7 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,41 @@ Mon Apr 4 15:30:49 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + Made sure that every call to bfd_read, bfd_write, and bfd_seek + checks the return value and handled bfd_error correctly. These + changes are not itemised. Also: + * aoutx.h (emit_strtab): Change return type to boolean, and return + errors. + (NAME(aout,write_syms)): Check emit_strtab return value. + (NAME(aout,final_link)): Likewise. + * coffcode.h (coff_write_relocs): Change return type to boolean, + and return errors. + (coff_write_object_contents): Check coff_write_relocs return + value. + * i386os9k.c (os9k_swap_exec_header_in): Change return type to + boolean. + (os9k_object_p): Check os9k_swap_exec_header_in return value. + * oasys.c (oasys_read_record): Change return type to boolean. + (oasys_slurp_symbol_table: Check oasys_read_record return value. + (oasys_object_p, oasys_slurp_section_data): Likewise. + (oasys_write_record): Change return type to boolean. + (oasys_write_syms): Likewise. Also, check oasys_write_record + return value. + (oasys_write_sections): Check oasys_write_record return value. + (oasys_write_header): Change return type to boolean. Check + oasys_write_record return value. + (oasys_write_end, oasys_write_data): Likewise. + (oasys_write_object_contents): Check return values of + oasys_write_header, oasys_write_syms, oasys_write_data, and + oasys_write_end. + * srec.c (srec_write_record): Change return type to boolean. + (srec_write_header): Likewise. Also, check srec_write_record + return value. + (srec_write_section, srec_write_terminator): Likewise. + (srec_write_symbols): Change return type to boolean. + (internal_srec_write_object_contents): Check return value of + srec_write_symbols, srec_write_header, srec_write_section, and + srec_write_terminator. + * Makefile.in: Rebuilt dependencies. Mon Apr 4 10:56:45 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) diff --git a/bfd/aout-adobe.c b/bfd/aout-adobe.c index 89961d7..3abd88e 100644 --- a/bfd/aout-adobe.c +++ b/bfd/aout-adobe.c @@ -99,7 +99,8 @@ aout_adobe_object_p (abfd) if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) != EXEC_BYTES_SIZE) { - bfd_set_error (bfd_error_wrong_format); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_wrong_format); return 0; } @@ -156,7 +157,8 @@ aout_adobe_callback (abfd) for (;;) { if (bfd_read ((PTR) ext, 1, sizeof (*ext), abfd) != sizeof (*ext)) { - bfd_set_error (bfd_error_wrong_format); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_wrong_format); return 0; } switch (ext->e_type[0]) { @@ -310,8 +312,10 @@ aout_adobe_write_object_contents (abfd) aout_adobe_swap_exec_header_out (abfd, exec_hdr (abfd), &swapped_hdr); - bfd_seek (abfd, (file_ptr) 0, SEEK_SET); - bfd_write ((PTR) &swapped_hdr, 1, EXEC_BYTES_SIZE, abfd); + if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 + || (bfd_write ((PTR) &swapped_hdr, 1, EXEC_BYTES_SIZE, abfd) + != EXEC_BYTES_SIZE)) + return false; /* Now write out the section information. Text first, data next, rest afterward. */ @@ -333,17 +337,23 @@ aout_adobe_write_object_contents (abfd) } /* Write final `sentinel` section header (with type of 0). */ - bfd_write ((PTR) sentinel, 1, sizeof (*sentinel), abfd); + if (bfd_write ((PTR) sentinel, 1, sizeof (*sentinel), abfd) + != sizeof (*sentinel)) + return false; /* Now write out reloc info, followed by syms and strings */ if (bfd_get_symcount (abfd) != 0) { - bfd_seek (abfd, (file_ptr)(N_SYMOFF(*exec_hdr(abfd))), SEEK_SET); + if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*exec_hdr(abfd))), SEEK_SET) + != 0) + return false; if (! aout_32_write_syms (abfd)) return false; - bfd_seek (abfd, (file_ptr)(N_TRELOFF(*exec_hdr(abfd))), SEEK_SET); + if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*exec_hdr(abfd))), SEEK_SET) + != 0) + return false; for (sect = abfd->sections; sect; sect = sect->next) { if (sect->flags & SEC_CODE) { @@ -352,7 +362,9 @@ aout_adobe_write_object_contents (abfd) } } - bfd_seek (abfd, (file_ptr)(N_DRELOFF(*exec_hdr(abfd))), SEEK_SET); + if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*exec_hdr(abfd))), SEEK_SET) + != 0) + return false; for (sect = abfd->sections; sect; sect = sect->next) { if (sect->flags & SEC_DATA) { @@ -417,7 +429,8 @@ aout_adobe_set_section_contents (abfd, section, location, offset, count) } /* regardless, once we know what we're doing, we might as well get going */ - bfd_seek (abfd, section->filepos + offset, SEEK_SET); + if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0) + return false; if (count != 0) { return (bfd_write ((PTR)location, 1, count, abfd) == count) ?true:false; diff --git a/bfd/aout-encap.c b/bfd/aout-encap.c index 0d468f2..dff9f74 100644 --- a/bfd/aout-encap.c +++ b/bfd/aout-encap.c @@ -69,7 +69,8 @@ encap_object_p (abfd) struct external_exec exec_bytes; if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) != EXEC_BYTES_SIZE) { - bfd_set_error (bfd_error_wrong_format); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_wrong_format); return 0; } NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec); diff --git a/bfd/aout-target.h b/bfd/aout-target.h index 6c2ace9..8d2f616 100644 --- a/bfd/aout-target.h +++ b/bfd/aout-target.h @@ -89,7 +89,8 @@ MY(object_p) (abfd) if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) != EXEC_BYTES_SIZE) { - bfd_set_error (bfd_error_wrong_format); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_wrong_format); return 0; } diff --git a/bfd/aoutf1.h b/bfd/aoutf1.h index dfac4eb..167f828 100644 --- a/bfd/aoutf1.h +++ b/bfd/aoutf1.h @@ -64,7 +64,12 @@ The name put into the target vector. /*SUPPRESS529*/ void - NAME (sunos, set_arch_mach) (abfd, machtype) +#if ARCH_SIZE == 64 +sunos_64_set_arch_mach +#else +sunos_32_set_arch_mach +#endif + (abfd, machtype) bfd *abfd; int machtype; { @@ -148,7 +153,12 @@ choose_reloc_size (abfd) file header, symbols, and relocation. */ static boolean - NAME (aout, sunos4_write_object_contents) (abfd) +#if ARCH_SIZE == 64 +aout_64_sunos4_write_object_contents +#else +aout_32_sunos4_write_object_contents +#endif + (abfd) bfd *abfd; { struct external_exec exec_bytes; @@ -384,7 +394,12 @@ swapcore_sun3 (abfd, ext, intcore) intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len); intcore->c_regs_pos = (long) (((struct external_sun3_core *) 0)->c_regs); intcore->c_regs_size = sizeof (extcore->c_regs); - NAME (aout, swap_exec_header_in) (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr); +#if ARCH_SIZE == 64 + aout_64_swap_exec_header_in +#else + aout_32_swap_exec_header_in +#endif + (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr); intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo); intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize); intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize); @@ -415,7 +430,12 @@ swapcore_sparc (abfd, ext, intcore) intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len); intcore->c_regs_pos = (long) (((struct external_sparc_core *) 0)->c_regs); intcore->c_regs_size = sizeof (extcore->c_regs); - NAME (aout, swap_exec_header_in) (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr); +#if ARCH_SIZE == 64 + aout_64_swap_exec_header_in +#else + aout_32_swap_exec_header_in +#endif + (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr); intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo); intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize); intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize); @@ -520,7 +540,6 @@ sunos4_core_file_p (abfd) if ((bfd_read ((PTR) extcore, 1, core_size, abfd)) != core_size) { - bfd_set_error (bfd_error_system_call); bfd_release (abfd, (char *) mergem); return 0; } diff --git a/bfd/archive.c b/bfd/archive.c index 589199b..d945ceb 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -389,7 +389,8 @@ _bfd_snarf_ar_hdr (abfd) if (bfd_read ((PTR) hdrp, 1, sizeof (struct ar_hdr), abfd) != sizeof (struct ar_hdr)) { - bfd_set_error (bfd_error_no_more_archived_files); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_no_more_archived_files); return NULL; } if (strncmp (hdr.ar_fmag, ARFMAG, 2)) @@ -442,7 +443,8 @@ _bfd_snarf_ar_hdr (abfd) + sizeof (struct ar_hdr)); if (bfd_read (filename, 1, namelen, abfd) != namelen) { - bfd_set_error (bfd_error_no_more_archived_files); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_no_more_archived_files); return NULL; } filename[namelen] = '\0'; @@ -633,7 +635,8 @@ bfd_generic_archive_p (abfd) if (bfd_read ((PTR) armag, 1, SARMAG, abfd) != SARMAG) { - bfd_set_error (bfd_error_wrong_format); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_wrong_format); return NULL; } @@ -727,7 +730,8 @@ do_slurp_bsd_armap (abfd) if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size) { - bfd_set_error (bfd_error_malformed_archive); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_malformed_archive); byebye: bfd_release (abfd, (PTR) raw_armap); return false; @@ -800,7 +804,8 @@ do_slurp_coff_armap (abfd) if (bfd_read ((PTR) int_buf, 1, 4, abfd) != 4) { - bfd_set_error (bfd_error_malformed_archive); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_malformed_archive); return false; } /* It seems that all numeric information in a coff archive is always @@ -849,7 +854,8 @@ do_slurp_coff_armap (abfd) if (bfd_read ((PTR) raw_armap, 1, ptrsize, abfd) != ptrsize || bfd_read ((PTR) stringbase, 1, stringsize, abfd) != stringsize) { - bfd_set_error (bfd_error_malformed_archive); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_malformed_archive); goto release_raw_armap; } @@ -895,7 +901,8 @@ bfd_slurp_armap (abfd) if (i != 16) return false; - bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR); + if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0) + return false; if (!strncmp (nextname, "__.SYMDEF ", 16)) return do_slurp_bsd_armap (abfd); @@ -933,7 +940,8 @@ bfd_slurp_bsd_armap_f2 (abfd) return false; /* The archive has at least 16 bytes in it */ - bfd_seek (abfd, -16L, SEEK_CUR); + if (bfd_seek (abfd, -16L, SEEK_CUR) != 0) + return false; if (!strncmp (nextname, "__.SYMDEF ", 16)) return do_slurp_bsd_armap (abfd); @@ -960,7 +968,8 @@ bfd_slurp_bsd_armap_f2 (abfd) if (bfd_read ((PTR) raw_armap, 1, mapdata->parsed_size, abfd) != mapdata->parsed_size) { - bfd_set_error (bfd_error_malformed_archive); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_malformed_archive); byebyebye: bfd_release (abfd, (PTR) raw_armap); goto byebye; @@ -1034,7 +1043,8 @@ _bfd_slurp_extended_name_table (abfd) if (bfd_read ((PTR) nextname, 1, 16, abfd) == 16) { - bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR); + if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0) + return false; if (strncmp (nextname, "ARFILENAMES/ ", 16) != 0 && strncmp (nextname, "// ", 16) != 0) @@ -1060,7 +1070,8 @@ _bfd_slurp_extended_name_table (abfd) if (bfd_read ((PTR) bfd_ardata (abfd)->extended_names, 1, namedata->parsed_size, abfd) != namedata->parsed_size) { - bfd_set_error (bfd_error_malformed_archive); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_malformed_archive); bfd_release (abfd, (PTR) (bfd_ardata (abfd)->extended_names)); bfd_ardata (abfd)->extended_names = NULL; goto byebye; @@ -1450,6 +1461,7 @@ _bfd_write_archive_contents (arch) unsigned int elength = 0; boolean makemap = bfd_has_map (arch); boolean hasobjects = false; /* if no .o's, don't bother to make a map */ + bfd_size_type wrote; unsigned int i; int tries; @@ -1490,12 +1502,15 @@ _bfd_write_archive_contents (arch) if (!bfd_construct_extended_name_table (arch, &etable, &elength)) return false; - bfd_seek (arch, (file_ptr) 0, SEEK_SET); + if (bfd_seek (arch, (file_ptr) 0, SEEK_SET) != 0) + return false; #ifdef GNU960 - bfd_write (BFD_GNU960_ARMAG (arch), 1, SARMAG, arch); + wrote = bfd_write (BFD_GNU960_ARMAG (arch), 1, SARMAG, arch); #else - bfd_write (ARMAG, 1, SARMAG, arch); + wrote = bfd_write (ARMAG, 1, SARMAG, arch); #endif + if (wrote != SARMAG) + return false; if (makemap && hasobjects) { @@ -1518,10 +1533,15 @@ _bfd_write_archive_contents (arch) for (i = 0; i < sizeof (struct ar_hdr); i++) if (((char *) (&hdr))[i] == '\0') (((char *) (&hdr))[i]) = ' '; - bfd_write ((char *) &hdr, 1, sizeof (struct ar_hdr), arch); - bfd_write (etable, 1, elength, arch); + if ((bfd_write ((char *) &hdr, 1, sizeof (struct ar_hdr), arch) + != sizeof (struct ar_hdr)) + || bfd_write (etable, 1, elength, arch) != elength) + return false; if ((elength % 2) == 1) - bfd_write ("\012", 1, 1, arch); + { + if (bfd_write ("\012", 1, 1, arch) != 1) + return false; + } } for (current = arch->archive_head; current; current = current->next) @@ -1552,7 +1572,10 @@ _bfd_write_archive_contents (arch) remaining -= amt; } if ((arelt_size (current) % 2) == 1) - bfd_write ("\012", 1, 1, arch); + { + if (bfd_write ("\012", 1, 1, arch) != 1) + return false; + } } /* Verify the timestamp in the archive file. If it would not be @@ -1780,9 +1803,12 @@ bsd_write_armap (arch, elength, map, orl_count, stridx) for (i = 0; i < sizeof (struct ar_hdr); i++) if (((char *) (&hdr))[i] == '\0') (((char *) (&hdr))[i]) = ' '; - bfd_write ((char *) &hdr, 1, sizeof (struct ar_hdr), arch); + if (bfd_write ((char *) &hdr, 1, sizeof (struct ar_hdr), arch) + != sizeof (struct ar_hdr)) + return false; bfd_h_put_32 (arch, (bfd_vma) ranlibsize, (PTR) &temp); - bfd_write (&temp, 1, sizeof (temp), arch); + if (bfd_write (&temp, 1, sizeof (temp), arch) != sizeof (temp)) + return false; for (count = 0; count < orl_count; count++) { @@ -1803,20 +1829,29 @@ bsd_write_armap (arch, elength, map, orl_count, stridx) last_elt = current; bfd_h_put_32 (arch, ((map[count]).namidx), (PTR) &outs.s.string_offset); bfd_h_put_32 (arch, firstreal, (PTR) &outs.file_offset); - bfd_write ((char *) outp, 1, sizeof (outs), arch); + if (bfd_write ((char *) outp, 1, sizeof (outs), arch) != sizeof (outs)) + return false; } /* now write the strings themselves */ bfd_h_put_32 (arch, stringsize, (PTR) &temp); - bfd_write ((PTR) &temp, 1, sizeof (temp), arch); + if (bfd_write ((PTR) &temp, 1, sizeof (temp), arch) != sizeof (temp)) + return false; for (count = 0; count < orl_count; count++) - bfd_write (*((map[count]).name), 1, - strlen (*((map[count]).name)) + 1, arch); + { + size_t len = strlen (*map[count].name) + 1; + + if (bfd_write (*map[count].name, 1, len, arch) != len) + return false; + } /* The spec sez this should be a newline. But in order to be bug-compatible for sun's ar we use a null. */ if (padit) - bfd_write ("", 1, 1, arch); + { + if (bfd_write ("", 1, 1, arch) != 1) + return false; + } return true; } @@ -1857,10 +1892,11 @@ bsd_update_armap_timestamp (arch) (hdr.ar_date)[i] = ' '; /* Write it into the file. */ - bfd_seek (arch, bfd_ardata (arch)->armap_datepos, SEEK_SET); - if (bfd_write (hdr.ar_date, sizeof (hdr.ar_date), 1, arch) - != sizeof (hdr.ar_date)) + if (bfd_seek (arch, bfd_ardata (arch)->armap_datepos, SEEK_SET) != 0 + || (bfd_write (hdr.ar_date, sizeof (hdr.ar_date), 1, arch) + != sizeof (hdr.ar_date))) { + /* FIXME: bfd can't call perror. */ perror ("Writing updated armap timestamp"); return true; /* Some error while writing */ } @@ -1928,7 +1964,9 @@ coff_write_armap (arch, elength, map, symbol_count, stridx) /* Write the ar header for this item and the number of symbols */ - bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), arch); + if (bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), arch) + != sizeof (struct ar_hdr)) + return false; bfd_write_bigendian_4byte_int (arch, symbol_count); @@ -1960,14 +1998,20 @@ coff_write_armap (arch, elength, map, symbol_count, stridx) /* now write the strings themselves */ for (count = 0; count < symbol_count; count++) - bfd_write ((PTR) * ((map[count]).name), - 1, - strlen (*((map[count]).name)) + 1, arch); + { + size_t len = strlen (*map[count].name) + 1; + + if (bfd_write (*map[count].name, 1, len, arch) != len) + return false; + } /* The spec sez this should be a newline. But in order to be bug-compatible for arc960 we use a null. */ if (padit) - bfd_write ("", 1, 1, arch); + { + if (bfd_write ("", 1, 1, arch) != 1) + return false; + } return true; } @@ -123,7 +123,8 @@ b_out_object_p (abfd) if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) != EXEC_BYTES_SIZE) { - bfd_set_error (bfd_error_wrong_format); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_wrong_format); return 0; } @@ -250,21 +251,28 @@ b_out_write_object_contents (abfd) bout_swap_exec_header_out (abfd, exec_hdr (abfd), &swapped_hdr); - bfd_seek (abfd, (file_ptr) 0, SEEK_SET); - bfd_write ((PTR) &swapped_hdr, 1, EXEC_BYTES_SIZE, abfd); + if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 + || (bfd_write ((PTR) &swapped_hdr, 1, EXEC_BYTES_SIZE, abfd) + != EXEC_BYTES_SIZE)) + return false; /* Now write out reloc info, followed by syms and strings */ if (bfd_get_symcount (abfd) != 0) { - bfd_seek (abfd, (file_ptr)(N_SYMOFF(*exec_hdr(abfd))), SEEK_SET); + if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*exec_hdr(abfd))), SEEK_SET) + != 0) + return false; if (! aout_32_write_syms (abfd)) return false; - bfd_seek (abfd, (file_ptr)(N_TROFF(*exec_hdr(abfd))), SEEK_SET); + if (bfd_seek (abfd, (file_ptr)(N_TROFF(*exec_hdr(abfd))), SEEK_SET) != 0) + return false; if (!b_out_squirt_out_relocs (abfd, obj_textsec (abfd))) return false; - bfd_seek (abfd, (file_ptr)(N_DROFF(*exec_hdr(abfd))), SEEK_SET); + if (bfd_seek (abfd, (file_ptr)(N_DROFF(*exec_hdr(abfd))), SEEK_SET) + != 0) + return false; if (!b_out_squirt_out_relocs (abfd, obj_datasec (abfd))) return false; } @@ -873,7 +881,8 @@ b_out_set_section_contents (abfd, section, location, offset, count) } /* regardless, once we know what we're doing, we might as well get going */ - bfd_seek (abfd, section->filepos + offset, SEEK_SET); + if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0) + return false; if (count != 0) { return (bfd_write ((PTR)location, 1, count, abfd) == count) ?true:false; diff --git a/bfd/cisco-core.c b/bfd/cisco-core.c index 2a916bf..5a94d51 100644 --- a/bfd/cisco-core.c +++ b/bfd/cisco-core.c @@ -67,8 +67,8 @@ cisco_core_file_p (abfd) nread = bfd_read (buf, 1, 4, abfd); if (nread != 4) { - /* Maybe the file is too small (FIXME: what about other errors). */ - bfd_set_error (bfd_error_wrong_format); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_wrong_format); return NULL; } crashinfo_offset = bfd_get_32 (abfd, buf); @@ -79,8 +79,8 @@ cisco_core_file_p (abfd) nread = bfd_read (&crashinfo, 1, sizeof (crashinfo), abfd); if (nread != sizeof (crashinfo)) { - /* Maybe the file is too small (FIXME: what about other errors). */ - bfd_set_error (bfd_error_wrong_format); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_wrong_format); return NULL; } diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c index e861043..b24c015 100644 --- a/bfd/coff-rs6000.c +++ b/bfd/coff-rs6000.c @@ -527,14 +527,16 @@ rs6000coff_snarf_ar_hdr (abfd) size = sizeof (h.hdr); if (bfd_read(&h.hdr, 1, size, abfd) != size) { - bfd_set_error (bfd_error_no_more_archived_files); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_no_more_archived_files); return NULL; } size = atoi(h.hdr.ar_namlen); /* ar_name[] length */ size += size & 1; if (bfd_read(&h.hdr._ar_name.ar_name[2], 1, size, abfd) != size) { - bfd_set_error (bfd_error_no_more_archived_files); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_no_more_archived_files); return NULL; } @@ -634,7 +636,8 @@ rs6000coff_archive_p (abfd) register struct artdata *art; if (bfd_read (&hdr, sizeof (hdr), 1, abfd) != sizeof (hdr)) { - bfd_set_error (bfd_error_wrong_format); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_wrong_format); return 0; } diff --git a/bfd/ecoff.c b/bfd/ecoff.c index 03975e6..fe786ab 100644 --- a/bfd/ecoff.c +++ b/bfd/ecoff.c @@ -3025,7 +3025,8 @@ ecoff_slurp_armap (abfd) if (i != 16) return false; - bfd_seek (abfd, (file_ptr) -16, SEEK_CUR); + if (bfd_seek (abfd, (file_ptr) -16, SEEK_CUR) != 0) + return false; /* Irix 4.0.5F apparently can use either an ECOFF armap or a standard COFF armap. We could move the ECOFF armap stuff into @@ -3078,7 +3079,8 @@ ecoff_slurp_armap (abfd) if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size) { - bfd_set_error (bfd_error_malformed_archive); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_malformed_archive); bfd_release (abfd, (PTR) raw_armap); return false; } @@ -3349,7 +3351,8 @@ ecoff_archive_p (abfd) if (bfd_read ((PTR) armag, 1, SARMAG, abfd) != SARMAG || strncmp (armag, ARMAG, SARMAG) != 0) { - bfd_set_error (bfd_error_wrong_format); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_wrong_format); return (bfd_target *) NULL; } diff --git a/bfd/elfcode.h b/bfd/elfcode.h index 19ce05d..7d94179 100644 --- a/bfd/elfcode.h +++ b/bfd/elfcode.h @@ -1545,8 +1545,10 @@ elf_write_phdrs (abfd, i_ehdrp, i_phdrp, phdr_cnt) for (i = 0; i < phdr_cnt; i++) { elf_swap_phdr_out (abfd, i_phdrp + i, &x_phdr); - bfd_seek (abfd, outbase, SEEK_SET); - bfd_write ((PTR) & x_phdr, sizeof (x_phdr), 1, abfd); + if (bfd_seek (abfd, outbase, SEEK_SET) != 0 + || (bfd_write ((PTR) & x_phdr, sizeof (x_phdr), 1, abfd) + != sizeof (x_phdr))) + return false; outbase += sizeof (x_phdr); } @@ -2301,8 +2303,10 @@ write_shdrs_and_ehdr (abfd) elf_debug_file (i_ehdrp); #endif elf_swap_ehdr_out (abfd, i_ehdrp, &x_ehdr); - bfd_seek (abfd, (file_ptr) 0, SEEK_SET); - bfd_write ((PTR) & x_ehdr, sizeof (x_ehdr), 1, abfd); + if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 + || (bfd_write ((PTR) & x_ehdr, sizeof (x_ehdr), 1, abfd) + != sizeof (x_ehdr))) + return false; /* at this point we've concocted all the ELF sections... */ x_shdrp = (Elf_External_Shdr *) @@ -2321,8 +2325,11 @@ write_shdrs_and_ehdr (abfd) #endif elf_swap_shdr_out (abfd, i_shdrp[count], x_shdrp + count); } - bfd_seek (abfd, (file_ptr) i_ehdrp->e_shoff, SEEK_SET); - bfd_write ((PTR) x_shdrp, sizeof (*x_shdrp), i_ehdrp->e_shnum, abfd); + if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_shoff, SEEK_SET) != 0 + || (bfd_write ((PTR) x_shdrp, sizeof (*x_shdrp), i_ehdrp->e_shnum, abfd) + != sizeof (*x_shdrp))) + return false; + /* need to dump the string table too... */ return true; @@ -2387,9 +2394,11 @@ NAME(bfd_elf,write_object_contents) (abfd) (*bed->elf_backend_section_processing) (abfd, i_shdrp[count]); if (i_shdrp[count]->contents) { - bfd_seek (abfd, i_shdrp[count]->sh_offset, SEEK_SET); - bfd_write (i_shdrp[count]->contents, i_shdrp[count]->sh_size, 1, - abfd); + if (bfd_seek (abfd, i_shdrp[count]->sh_offset, SEEK_SET) != 0 + || (bfd_write (i_shdrp[count]->contents, i_shdrp[count]->sh_size, + 1, abfd) + != i_shdrp[count]->sh_size)) + return false; } } @@ -2793,7 +2802,8 @@ elf_slurp_reloca_table (abfd, asect, symbols) if (asect->flags & SEC_CONSTRUCTOR) return true; - bfd_seek (abfd, asect->rel_filepos, SEEK_SET); + if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0) + return false; native_relocs = (Elf_External_Rela *) bfd_alloc (abfd, asect->reloc_count * sizeof (Elf_External_Rela)); if (!native_relocs) @@ -2801,8 +2811,10 @@ elf_slurp_reloca_table (abfd, asect, symbols) bfd_set_error (bfd_error_no_memory); return false; } - bfd_read ((PTR) native_relocs, - sizeof (Elf_External_Rela), asect->reloc_count, abfd); + if (bfd_read ((PTR) native_relocs, + sizeof (Elf_External_Rela), asect->reloc_count, abfd) + != sizeof (Elf_External_Rela) * asect->reloc_count) + return false; reloc_cache = (arelent *) bfd_alloc (abfd, (size_t) (asect->reloc_count * sizeof (arelent))); @@ -2940,7 +2952,8 @@ elf_slurp_reloc_table (abfd, asect, symbols) if (asect->flags & SEC_CONSTRUCTOR) return true; - bfd_seek (abfd, asect->rel_filepos, SEEK_SET); + if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0) + return false; native_relocs = (Elf_External_Rel *) bfd_alloc (abfd, asect->reloc_count * sizeof (Elf_External_Rel)); if (!native_relocs) @@ -2948,8 +2961,10 @@ elf_slurp_reloc_table (abfd, asect, symbols) bfd_set_error (bfd_error_no_memory); return false; } - bfd_read ((PTR) native_relocs, - sizeof (Elf_External_Rel), asect->reloc_count, abfd); + if (bfd_read ((PTR) native_relocs, + sizeof (Elf_External_Rel), asect->reloc_count, abfd) + != sizeof (Elf_External_Rel) * asect->reloc_count) + return false; reloc_cache = (arelent *) bfd_alloc (abfd, (size_t) (asect->reloc_count * sizeof (arelent))); diff --git a/bfd/hp300hpux.c b/bfd/hp300hpux.c index d73ab1a..3b8cb9c 100644 --- a/bfd/hp300hpux.c +++ b/bfd/hp300hpux.c @@ -283,8 +283,10 @@ MY (write_object_contents) (abfd) /* this is really the sym table size but we store it in drelocs */ bfd_h_put_32 (abfd, bfd_get_symcount (abfd) * 12, exec_bytes.e_drelocs); - bfd_seek (abfd, 0L, false); - bfd_write ((PTR) & exec_bytes, 1, EXEC_BYTES_SIZE, abfd); + if (bfd_seek (abfd, 0L, false) != 0 + || (bfd_write ((PTR) & exec_bytes, 1, EXEC_BYTES_SIZE, abfd) + != EXEC_BYTES_SIZE)) + return false; /* Write out the symbols, and then the relocs. We must write out the symbols first so that we know the symbol indices. */ @@ -302,12 +304,12 @@ MY (write_object_contents) (abfd) if (bfd_get_symcount (abfd) != 0) { - bfd_seek (abfd, (long) (N_TRELOFF (*execp)), false); - + if (bfd_seek (abfd, (long) (N_TRELOFF (*execp)), false) != 0) + return false; if (!NAME (aout, squirt_out_relocs) (abfd, obj_textsec (abfd))) return false; - bfd_seek (abfd, (long) (N_DRELOFF (*execp)), false); - + if (bfd_seek (abfd, (long) (N_DRELOFF (*execp)), false) != 0) + return false; if (!NAME (aout, squirt_out_relocs) (abfd, obj_datasec (abfd))) return false; } @@ -503,8 +505,8 @@ MY (slurp_symbol_table) (abfd) return false; } syms = (struct external_nlist *) (strings + SYM_EXTRA_BYTES); - bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET); - if (bfd_read ((PTR) syms, symbol_bytes, 1, abfd) != symbol_bytes) + if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0 + || bfd_read ((PTR) syms, symbol_bytes, 1, abfd) != symbol_bytes) { bfd_release (abfd, syms); return false; @@ -739,7 +741,8 @@ MY (slurp_reloc_table) (abfd, asect, symbols) return false; doit: - bfd_seek (abfd, asect->rel_filepos, SEEK_SET); + if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0) + return false; each_size = obj_reloc_entry_size (abfd); count = reloc_size / each_size; diff --git a/bfd/hppabsd-core.c b/bfd/hppabsd-core.c index 96b82d0..bc99ff5 100644 --- a/bfd/hppabsd-core.c +++ b/bfd/hppabsd-core.c @@ -130,7 +130,8 @@ hppabsd_core_core_file_p (abfd) val = bfd_read ((void *) &u, 1, sizeof u, abfd); if (val != sizeof u) { - bfd_set_error (bfd_error_wrong_format); + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_wrong_format); return NULL; } diff --git a/bfd/hpux-core.c b/bfd/hpux-core.c index ef9f32d..81b0e53 100644 --- a/bfd/hpux-core.c +++ b/bfd/hpux-core.c @@ -136,7 +136,9 @@ hpux_core_core_file_p (abfd) case CORE_EXEC: { struct proc_exec proc_exec; - bfd_read ((void *) &proc_exec, 1, core_header.len, abfd); + if (bfd_read ((void *) &proc_exec, 1, core_header.len, abfd) + != core_header.len) + break; strncpy (core_command (abfd), proc_exec.cmd, MAXCOMLEN + 1); } break; @@ -148,7 +150,9 @@ hpux_core_core_file_p (abfd) core_header.len, (int) &proc_info - (int) &proc_info.hw_regs, 2); - bfd_read (&proc_info, 1, core_header.len, abfd); + if (bfd_read (&proc_info, 1, core_header.len, abfd) + != core_header.len) + break; core_signal (abfd) = proc_info.sig; } if (!core_regsec (abfd)) diff --git a/bfd/i386lynx.c b/bfd/i386lynx.c index e643dad..784a6f2 100644 --- a/bfd/i386lynx.c +++ b/bfd/i386lynx.c @@ -50,22 +50,32 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ obj_reloc_entry_size (abfd)); \ NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes); \ \ - bfd_seek (abfd, (file_ptr) 0, SEEK_SET); \ - bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd); \ + if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return false; \ + if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) \ + != EXEC_BYTES_SIZE) \ + return false; \ /* Now write out reloc info, followed by syms and strings */ \ \ if (bfd_get_symcount (abfd) != 0) \ { \ - bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET); \ + if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET) \ + != 0) \ + return false; \ \ if (! NAME(aout,write_syms)(abfd)) return false; \ \ - bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET); \ + if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET) \ + != 0) \ + return false; \ \ - if (!NAME(lynx,squirt_out_relocs) (abfd, obj_textsec (abfd))) return false; \ - bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET); \ + if (!NAME(lynx,squirt_out_relocs) (abfd, obj_textsec (abfd))) \ + return false; \ + if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET) \ + != 0) \ + return 0; \ \ - if (!NAME(lynx,squirt_out_relocs)(abfd, obj_datasec (abfd))) return false; \ + if (!NAME(lynx,squirt_out_relocs)(abfd, obj_datasec (abfd))) \ + return false; \ } \ } #endif @@ -41,7 +41,8 @@ ieee_write_byte (abfd, byte) bfd *abfd; bfd_byte byte; { - bfd_write ((PTR) & byte, 1, 1, abfd); + if (bfd_write ((PTR) & byte, 1, 1, abfd) != 1) + abort (); } static void @@ -52,7 +53,8 @@ ieee_write_twobyte (abfd, twobyte) bfd_byte b[2]; b[1] = twobyte & 0xff; b[0] = twobyte >> 8; - bfd_write ((PTR) & b[0], 1, 2, abfd); + if (bfd_write ((PTR) & b[0], 1, 2, abfd) != 2) + abort (); } static void @@ -64,7 +66,8 @@ ieee_write_2bytes (abfd, bytes) buffer[0] = bytes >> 8; buffer[1] = bytes & 0xff; - bfd_write ((PTR) buffer, 1, 2, abfd); + if (bfd_write ((PTR) buffer, 1, 2, abfd) != 2) + abort (); } static void @@ -137,7 +140,8 @@ ieee_write_id (abfd, id) { BFD_FAIL (); } - bfd_write ((PTR) id, 1, length, abfd); + if (bfd_write ((PTR) id, 1, length, abfd) != length) + abort (); } @@ -307,7 +311,8 @@ ieee_write_int5_out (abfd, value) { bfd_byte b[5]; ieee_write_int5 (b, value); - bfd_write ((PTR) b, 1, 5, abfd); + if (bfd_write ((PTR) b, 1, 5, abfd) != 5) + abort (); } static boolean @@ -1068,6 +1073,8 @@ ieee_archive_p (abfd) } ieee = IEEE_AR_DATA (abfd); + /* FIXME: Check return value. I'm not sure whether it needs to read + the entire buffer or not. */ bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd); ieee->h.first_byte = buffer; @@ -1128,7 +1135,10 @@ ieee_archive_p (abfd) { /* Past half way, reseek and reprime */ buffer_offset += ieee_pos (abfd); - bfd_seek (abfd, buffer_offset, SEEK_SET); + if (bfd_seek (abfd, buffer_offset, SEEK_SET) != 0) + return NULL; + /* FIXME: Check return value. I'm not sure whether it + needs to read the entire buffer or not. */ bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd); ieee->h.first_byte = buffer; ieee->h.input_p = buffer; @@ -1150,7 +1160,10 @@ ieee_archive_p (abfd) for (i = 2; i < ieee->element_count; i++) { - bfd_seek (abfd, ieee->elements[i].file_offset, SEEK_SET); + if (bfd_seek (abfd, ieee->elements[i].file_offset, SEEK_SET) != 0) + return NULL; + /* FIXME: Check return value. I'm not sure whether it needs to + read the entire buffer or not. */ bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd); ieee->h.first_byte = buffer; ieee->h.input_p = buffer; @@ -1195,8 +1208,11 @@ ieee_object_p (abfd) ieee_mkobject (abfd); ieee = IEEE_DATA (abfd); - bfd_seek (abfd, (file_ptr) 0, SEEK_SET); + if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) + goto fail; /* Read the first few bytes in to see if it makes sense */ + /* FIXME: Check return value. I'm not sure whether it needs to read + the entire buffer or not. */ bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd); ieee->h.input_p = buffer; @@ -1282,7 +1298,10 @@ ieee_object_p (abfd) bfd_set_error (bfd_error_no_memory); goto fail; } - bfd_seek (abfd, (file_ptr) 0, SEEK_SET); + if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) + goto fail; + /* FIXME: Check return value. I'm not sure whether it needs to read + the entire buffer or not. */ bfd_read ((PTR) (IEEE_DATA (abfd)->h.first_byte), 1, ieee->w.r.me_record + 50, abfd); ieee_slurp_sections (abfd); @@ -1885,10 +1904,12 @@ do_with_relocs (abfd, s) ieee_write_byte (abfd, ieee_load_constant_bytes_enum); /* Output a stream of bytes */ ieee_write_int (abfd, run); - bfd_write ((PTR) (stream + current_byte_index), - 1, - run, - abfd); + if (bfd_write ((PTR) (stream + current_byte_index), + 1, + run, + abfd) + != run) + return false; current_byte_index += run; } } @@ -1934,10 +1955,12 @@ do_with_relocs (abfd, s) { /* Output a stream of bytes */ ieee_write_int (abfd, run); - bfd_write ((PTR) (stream + current_byte_index), - 1, - run, - abfd); + if (bfd_write ((PTR) (stream + current_byte_index), + 1, + run, + abfd) + != run) + return false; current_byte_index += run; } /* Output any relocations here */ @@ -2079,13 +2102,18 @@ static int output_buffer; static void fill () { + /* FIXME: Check return value. I'm not sure whether it needs to read + the entire buffer or not. */ bfd_read ((PTR) input_ptr_start, 1, input_ptr_end - input_ptr_start, input_bfd); input_ptr = input_ptr_start; } static void flush () { - bfd_write ((PTR) (output_ptr_start), 1, output_ptr - output_ptr_start, output_bfd); + if (bfd_write ((PTR) (output_ptr_start), 1, output_ptr - output_ptr_start, + output_bfd) + != output_ptr - output_ptr_start) + abort (); output_ptr = output_ptr_start; output_buffer++; } @@ -2732,6 +2760,8 @@ relocate_debug (output, input) input_ptr_start = input_ptr = input_buffer; input_ptr_end = input_buffer + IBS; input_bfd = input; + /* FIXME: Check return value. I'm not sure whether it needs to read + the entire buffer or not. */ bfd_read ((PTR) input_ptr_start, 1, IBS, input); block (); } @@ -2811,7 +2841,10 @@ ieee_write_debug_part (abfd) ieee_data_type *entry_ieee = IEEE_DATA (entry); if (entry_ieee->w.r.debug_information_part) { - bfd_seek (entry, entry_ieee->w.r.debug_information_part, SEEK_SET); + if (bfd_seek (entry, entry_ieee->w.r.debug_information_part, + SEEK_SET) + != 0) + abort (); relocate_debug (abfd, entry); } @@ -3056,7 +3089,8 @@ ieee_write_object_contents (abfd) unsigned int i; file_ptr old; /* Fast forward over the header area */ - bfd_seek (abfd, (file_ptr) 0, SEEK_SET); + if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) + return false; ieee_write_byte (abfd, ieee_module_beginning_enum); ieee_write_id (abfd, bfd_printable_name (abfd)); @@ -3072,17 +3106,20 @@ ieee_write_object_contents (abfd) (bfd_byte) (bfd_arch_bits_per_address (abfd) / bfd_arch_bits_per_byte (abfd))); old = bfd_tell (abfd); - bfd_seek (abfd, (file_ptr) (8 * N_W_VARIABLES), SEEK_CUR); + if (bfd_seek (abfd, (file_ptr) (8 * N_W_VARIABLES), SEEK_CUR) != 0) + return false; ieee->w.r.extension_record = bfd_tell (abfd); - bfd_write ((char *) exten, 1, sizeof (exten), abfd); + if (bfd_write ((char *) exten, 1, sizeof (exten), abfd) != sizeof (exten)) + return false; if (abfd->flags & EXEC_P) ieee_write_byte (abfd, 0x1);/* Absolute */ else ieee_write_byte (abfd, 0x2);/* Relocateable */ ieee->w.r.environmental_record = bfd_tell (abfd); - bfd_write ((char *) envi, 1, sizeof (envi), abfd); + if (bfd_write ((char *) envi, 1, sizeof (envi), abfd) != sizeof (envi)) + return false; output_bfd = abfd; flush (); @@ -3118,7 +3155,8 @@ ieee_write_object_contents (abfd) /* Generate the header */ - bfd_seek (abfd, old, SEEK_SET); + if (bfd_seek (abfd, old, SEEK_SET) != 0) + return false; for (i = 0; i < N_W_VARIABLES; i++) { diff --git a/bfd/irix-core.c b/bfd/irix-core.c index 279fb4a..0a578cf 100644 --- a/bfd/irix-core.c +++ b/bfd/irix-core.c @@ -80,7 +80,11 @@ irix_core_core_file_p (abfd) val = bfd_read ((PTR)&coreout, 1, sizeof coreout, abfd); if (val != sizeof coreout) - return 0; + { + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_wrong_format); + return 0; + } if (coreout.c_magic != CORE_MAGIC || coreout.c_version != CORE_VERSION1) @@ -93,7 +97,8 @@ irix_core_core_file_p (abfd) strncpy (core_command (abfd), coreout.c_name, CORE_NAMESIZE); core_signal (abfd) = coreout.c_sigcause; - bfd_seek (abfd, coreout.c_vmapoffset, SEEK_SET); + if (bfd_seek (abfd, coreout.c_vmapoffset, SEEK_SET) != 0) + return NULL; for (i = 0; i < coreout.c_nvmap; i++) { @@ -139,7 +144,8 @@ irix_core_core_file_p (abfd) || idf->i_offset + idf->i_len != ids->i_offset) return 0; /* Can't deal with non-contig regs */ - bfd_seek (abfd, idg->i_offset, SEEK_SET); + if (bfd_seek (abfd, idg->i_offset, SEEK_SET) != 0) + return NULL; make_bfd_asection (abfd, ".reg", SEC_ALLOC+SEC_HAS_CONTENTS, diff --git a/bfd/libaout.h b/bfd/libaout.h index 0b22dee..9a3cecc 100644 --- a/bfd/libaout.h +++ b/bfd/libaout.h @@ -434,23 +434,33 @@ aout_stab_name PARAMS ((int code)); obj_reloc_entry_size (abfd)); \ NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes); \ \ - bfd_seek (abfd, (file_ptr) 0, SEEK_SET); \ - bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd); \ + if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return false; \ + if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) \ + != EXEC_BYTES_SIZE) \ + return false; \ /* Now write out reloc info, followed by syms and strings */ \ \ if (bfd_get_outsymbols (abfd) != (asymbol **) NULL \ && bfd_get_symcount (abfd) != 0) \ { \ - bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET); \ + if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET) \ + != 0) \ + return false; \ \ if (! NAME(aout,write_syms)(abfd)) return false; \ \ - bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET); \ + if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET) \ + != 0) \ + return false; \ \ - if (!NAME(aout,squirt_out_relocs) (abfd, obj_textsec (abfd))) return false; \ - bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET); \ + if (!NAME(aout,squirt_out_relocs) (abfd, obj_textsec (abfd))) \ + return false; \ + if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET) \ + != 0) \ + return false; \ \ - if (!NAME(aout,squirt_out_relocs)(abfd, obj_datasec (abfd))) return false; \ + if (!NAME(aout,squirt_out_relocs)(abfd, obj_datasec (abfd))) \ + return false; \ } \ } #endif diff --git a/bfd/libbfd.c b/bfd/libbfd.c index da3460b..93522d9 100644 --- a/bfd/libbfd.c +++ b/bfd/libbfd.c @@ -248,7 +248,8 @@ bfd_write_bigendian_4byte_int (abfd, i) { bfd_byte buffer[4]; bfd_putb32(i, buffer); - bfd_write((PTR)buffer, 4, 1, abfd); + if (bfd_write((PTR)buffer, 4, 1, abfd) != 4) + abort (); } long diff --git a/bfd/nlm32-ppc.c b/bfd/nlm32-ppc.c index 77c32a2..c46f94b 100644 --- a/bfd/nlm32-ppc.c +++ b/bfd/nlm32-ppc.c @@ -454,10 +454,7 @@ nlm_powerpc_read_reloc (abfd, sym, secp, rel) /* Read the reloc from the file. */ if (bfd_read (&ext, sizeof ext, 1, abfd) != sizeof ext) - { - bfd_set_error (bfd_error_system_call); - return false; - } + return false; /* Swap in the fields. */ l_vaddr = bfd_h_get_32 (abfd, ext.l_vaddr); @@ -556,10 +553,7 @@ nlm_powerpc_read_import (abfd, sym) if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd) != sizeof (symlength)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); sym -> symbol.the_bfd = abfd; name = bfd_alloc (abfd, symlength + 1); if (name == NULL) @@ -568,20 +562,14 @@ nlm_powerpc_read_import (abfd, sym) return false; } if (bfd_read (name, symlength, 1, abfd) != symlength) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); name[symlength] = '\0'; sym -> symbol.name = name; sym -> symbol.flags = 0; sym -> symbol.value = 0; sym -> symbol.section = &bfd_und_section; if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); rcount = bfd_h_get_32 (abfd, temp); nlm_relocs = ((struct nlm_relent *) bfd_alloc (abfd, rcount * sizeof (struct nlm_relent))); @@ -740,17 +728,11 @@ nlm_powerpc_write_external (abfd, count, sym, relocs) len = strlen (sym->name); if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof(bfd_byte)) || bfd_write (sym->name, len, 1, abfd) != len) - { - bfd_set_error (bfd_error_system_call); - return false; - } + return false; bfd_put_32 (abfd, count, temp); if (bfd_write (temp, sizeof(temp), 1, abfd) != sizeof (temp)) - { - bfd_set_error (bfd_error_system_call); - return false; - } + return false; for (i = 0; i < count; i++) { diff --git a/bfd/nlmcode.h b/bfd/nlmcode.h index a05c5f1..1ae6cc9 100644 --- a/bfd/nlmcode.h +++ b/bfd/nlmcode.h @@ -121,7 +121,12 @@ nlm_object_p (abfd) if (bfd_read ((PTR) x_fxdhdr, nlm_fixed_header_size (abfd), 1, abfd) != nlm_fixed_header_size (abfd)) - goto got_wrong_format_error; + { + if (bfd_get_error () != bfd_error_system_call) + goto got_wrong_format_error; + else + goto got_no_match; + } /* Allocate an instance of the nlm_obj_tdata structure and hook it up to the tdata pointer in the bfd. */ @@ -246,35 +251,23 @@ nlm_swap_variable_header_in (abfd) sizeof (nlm_variable_header (abfd)->descriptionLength), 1, abfd) != sizeof (nlm_variable_header (abfd)->descriptionLength)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); if (bfd_read ((PTR) nlm_variable_header (abfd)->descriptionText, nlm_variable_header (abfd)->descriptionLength + 1, 1, abfd) != nlm_variable_header (abfd)->descriptionLength + 1) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); /* Read and convert the stackSize field. */ if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); nlm_variable_header (abfd)->stackSize = get_word (abfd, (bfd_byte *) temp); /* Read and convert the reserved field. */ if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); nlm_variable_header (abfd)->reserved = get_word (abfd, (bfd_byte *) temp); /* Read the oldThreadName field. This field is a fixed length string. */ @@ -283,10 +276,7 @@ nlm_swap_variable_header_in (abfd) sizeof (nlm_variable_header (abfd)->oldThreadName), 1, abfd) != sizeof (nlm_variable_header (abfd)->oldThreadName)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); /* Read the screen name length and text members. */ @@ -294,18 +284,12 @@ nlm_swap_variable_header_in (abfd) sizeof (nlm_variable_header (abfd)->screenNameLength), 1, abfd) != sizeof (nlm_variable_header (abfd)->screenNameLength)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); if (bfd_read ((PTR) nlm_variable_header (abfd)->screenName, nlm_variable_header (abfd)->screenNameLength + 1, 1, abfd) != nlm_variable_header (abfd)->screenNameLength + 1) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); /* Read the thread name length and text members. */ @@ -313,18 +297,12 @@ nlm_swap_variable_header_in (abfd) sizeof (nlm_variable_header (abfd)->threadNameLength), 1, abfd) != sizeof (nlm_variable_header (abfd)->threadNameLength)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); if (bfd_read ((PTR) nlm_variable_header (abfd)->threadName, nlm_variable_header (abfd)->threadNameLength + 1, 1, abfd) != nlm_variable_header (abfd)->threadNameLength + 1) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); return (true); } @@ -343,38 +321,26 @@ nlm_swap_variable_header_out (abfd) sizeof (nlm_variable_header (abfd)->descriptionLength), 1, abfd) != sizeof (nlm_variable_header (abfd)->descriptionLength)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); if (bfd_write ((PTR) nlm_variable_header (abfd)->descriptionText, nlm_variable_header (abfd)->descriptionLength + 1, 1, abfd) != nlm_variable_header (abfd)->descriptionLength + 1) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); /* Convert and write the stackSize field. */ put_word (abfd, (bfd_vma) nlm_variable_header (abfd)->stackSize, (bfd_byte *) temp); if (bfd_write ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); /* Convert and write the reserved field. */ put_word (abfd, (bfd_vma) nlm_variable_header (abfd)->reserved, (bfd_byte *) temp); if (bfd_write ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); /* Write the oldThreadName field. This field is a fixed length string. */ @@ -382,10 +348,7 @@ nlm_swap_variable_header_out (abfd) sizeof (nlm_variable_header (abfd)->oldThreadName), 1, abfd) != sizeof (nlm_variable_header (abfd)->oldThreadName)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); /* Write the screen name length and text members. */ @@ -393,18 +356,12 @@ nlm_swap_variable_header_out (abfd) sizeof (nlm_variable_header (abfd)->screenNameLength), 1, abfd) != sizeof (nlm_variable_header (abfd)->screenNameLength)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); if (bfd_write ((PTR) nlm_variable_header (abfd)->screenName, nlm_variable_header (abfd)->screenNameLength + 1, 1, abfd) != nlm_variable_header (abfd)->screenNameLength + 1) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); /* Write the thread name length and text members. */ @@ -412,18 +369,12 @@ nlm_swap_variable_header_out (abfd) sizeof (nlm_variable_header (abfd)->threadNameLength), 1, abfd) != sizeof (nlm_variable_header (abfd)->threadNameLength)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); if (bfd_write ((PTR) nlm_variable_header (abfd)->threadName, nlm_variable_header (abfd)->threadNameLength + 1, 1, abfd) != nlm_variable_header (abfd)->threadNameLength + 1) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); return (true); } @@ -448,23 +399,14 @@ nlm_swap_auxiliary_headers_in (abfd) position = bfd_tell (abfd); if (bfd_read ((PTR) tempstr, sizeof (tempstr), 1, abfd) != sizeof (tempstr)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); if (bfd_seek (abfd, position, SEEK_SET) == -1) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); if (strncmp (tempstr, "VeRsIoN#", 8) == 0) { Nlm_External_Version_Header thdr; if (bfd_read ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); memcpy (nlm_version_header (abfd)->stamp, thdr.stamp, sizeof (thdr.stamp)); nlm_version_header (abfd)->majorVersion = @@ -484,10 +426,7 @@ nlm_swap_auxiliary_headers_in (abfd) { Nlm_External_Extended_Header thdr; if (bfd_read ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); memcpy (nlm_extended_header (abfd)->stamp, thdr.stamp, sizeof (thdr.stamp)); nlm_extended_header (abfd)->languageID = @@ -553,10 +492,7 @@ nlm_swap_auxiliary_headers_in (abfd) { Nlm_External_Custom_Header thdr; if (bfd_read ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); memcpy (nlm_custom_header (abfd)->stamp, thdr.stamp, sizeof (thdr.stamp)); nlm_custom_header (abfd)->dataLength = @@ -572,26 +508,17 @@ nlm_swap_auxiliary_headers_in (abfd) sizeof (nlm_copyright_header (abfd)->stamp), 1, abfd) != sizeof (nlm_copyright_header (abfd)->stamp)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); if (bfd_read ((PTR) & (nlm_copyright_header (abfd) ->copyrightMessageLength), 1, 1, abfd) != 1) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); /* The copyright message is a variable length string. */ if (bfd_read ((PTR) nlm_copyright_header (abfd)->copyrightMessage, nlm_copyright_header (abfd)->copyrightMessageLength + 1, 1, abfd) != nlm_copyright_header (abfd)->copyrightMessageLength + 1) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); } else { @@ -644,10 +571,7 @@ nlm_swap_auxiliary_headers_out (abfd) put_word (abfd, (bfd_vma) nlm_version_header (abfd)->day, (bfd_byte *) thdr.day); if (bfd_write ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) - { - bfd_set_error (bfd_error_system_call); - return false; - } + return false; } /* Write out the extended header if there is one. */ @@ -745,10 +669,7 @@ nlm_swap_auxiliary_headers_out (abfd) (bfd_vma) nlm_extended_header (abfd)->reserved5, (bfd_byte *) thdr.reserved5); if (bfd_write ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) - { - bfd_set_error (bfd_error_system_call); - return false; - } + return false; } /* Write out the custom header if there is one. */ @@ -769,10 +690,7 @@ nlm_swap_auxiliary_headers_out (abfd) put_word (abfd, (bfd_vma) nlm_custom_header (abfd)->debugRecLength, (bfd_byte *) thdr.debugRecLength); if (bfd_write ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) - { - bfd_set_error (bfd_error_system_call); - return false; - } + return false; } /* Write out the copyright header if there is one. */ @@ -784,26 +702,17 @@ nlm_swap_auxiliary_headers_out (abfd) memcpy (thdr.stamp, "CoPyRiGhT=", 10); if (bfd_write ((PTR) thdr.stamp, sizeof (thdr.stamp), 1, abfd) != sizeof (thdr.stamp)) - { - bfd_set_error (bfd_error_system_call); - return false; - } + return false; thdr.copyrightMessageLength[0] = nlm_copyright_header (abfd)->copyrightMessageLength; if (bfd_write ((PTR) thdr.copyrightMessageLength, 1, 1, abfd) != 1) - { - bfd_set_error (bfd_error_system_call); - return false; - } + return false; /* The copyright message is a variable length string. */ if (bfd_write ((PTR) nlm_copyright_header (abfd)->copyrightMessage, nlm_copyright_header (abfd)->copyrightMessageLength + 1, 1, abfd) != nlm_copyright_header (abfd)->copyrightMessageLength + 1) - { - bfd_set_error (bfd_error_system_call); - return false; - } + return false; } return true; @@ -966,10 +875,7 @@ nlm_slurp_symbol_table (abfd) } if (bfd_seek (abfd, i_fxdhdrp->publicsOffset, SEEK_SET) == -1) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); sym = ((nlm_symbol_type *) bfd_zalloc (abfd, totsymcount * sizeof (nlm_symbol_type))); @@ -990,10 +896,7 @@ nlm_slurp_symbol_table (abfd) { if (bfd_read ((PTR) & symlength, sizeof (symlength), 1, abfd) != sizeof (symlength)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); sym->symbol.the_bfd = abfd; sym->symbol.name = bfd_alloc (abfd, symlength + 1); if (!sym->symbol.name) @@ -1003,17 +906,11 @@ nlm_slurp_symbol_table (abfd) } if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd) != symlength) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); /* Cast away const. */ ((char *) (sym->symbol.name))[symlength] = '\0'; if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp)) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); sym->symbol.flags = BSF_GLOBAL | BSF_EXPORT; sym->symbol.value = get_word (abfd, temp); if (set_public_section_func) @@ -1048,10 +945,7 @@ nlm_slurp_symbol_table (abfd) if (i_fxdhdrp->numberOfDebugRecords > 0) { if (bfd_seek (abfd, i_fxdhdrp->debugInfoOffset, SEEK_SET) == -1) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); symcount += i_fxdhdrp->numberOfDebugRecords; while (abfd->symcount < symcount) @@ -1061,10 +955,7 @@ nlm_slurp_symbol_table (abfd) || bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp) || (bfd_read ((PTR) & symlength, sizeof (symlength), 1, abfd) != sizeof (symlength))) - { - bfd_set_error (bfd_error_system_call); - return false; - } + return false; sym->symbol.the_bfd = abfd; sym->symbol.name = bfd_alloc (abfd, symlength + 1); if (!sym->symbol.name) @@ -1074,10 +965,7 @@ nlm_slurp_symbol_table (abfd) } if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd) != symlength) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); /* Cast away const. */ ((char *) (sym->symbol.name))[symlength] = '\0'; sym->symbol.flags = BSF_LOCAL; @@ -1111,10 +999,7 @@ nlm_slurp_symbol_table (abfd) { if (bfd_seek (abfd, i_fxdhdrp->externalReferencesOffset, SEEK_SET) == -1) - { - bfd_set_error (bfd_error_system_call); - return (false); - } + return (false); symcount += i_fxdhdrp->numberOfExternalReferences; while (abfd->symcount < symcount) @@ -1160,10 +1045,7 @@ nlm_slurp_reloc_fixups (abfd) if (bfd_seek (abfd, nlm_fixed_header (abfd)->relocationFixupOffset, SEEK_SET) != 0) - { - bfd_set_error (bfd_error_system_call); - return false; - } + return false; count = nlm_fixed_header (abfd)->numberOfRelocationFixups; rels = (arelent *) bfd_alloc (abfd, count * sizeof (arelent)); @@ -1554,10 +1436,7 @@ nlm_set_section_contents (abfd, section, location, offset, count) if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0 || bfd_write (location, 1, count, abfd) != count) - { - bfd_set_error (bfd_error_system_call); - return false; - } + return false; return true; } @@ -1641,10 +1520,7 @@ nlm_write_object_contents (abfd) if (bfd_seek (abfd, nlm_optional_prefix_size (abfd) + nlm_fixed_header_size (abfd), SEEK_SET) != 0) - { - bfd_set_error (bfd_error_system_call); - goto error_return; - } + goto error_return; if (nlm_swap_variable_header_out (abfd) == false || nlm_swap_auxiliary_headers_out (abfd) == false) { @@ -1663,10 +1539,7 @@ nlm_write_object_contents (abfd) /* Advance to the relocs. */ if (bfd_seek (abfd, nlm_fixed_header (abfd)->relocationFixupOffset, SEEK_SET) != 0) - { - bfd_set_error (bfd_error_system_call); - goto error_return; - } + goto error_return; /* The format of the relocation entries is dependent upon the particular target. We use an external routine to write the reloc @@ -1866,17 +1739,11 @@ nlm_write_object_contents (abfd) if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof (bfd_byte)) || bfd_write (sym->name, len, 1, abfd) != len) - { - bfd_set_error (bfd_error_system_call); - goto error_return; - } + goto error_return; put_word (abfd, offset, temp); if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp)) - { - bfd_set_error (bfd_error_system_call); - goto error_return; - } + goto error_return; } } nlm_fixed_header (abfd)->numberOfPublics = c; @@ -1936,26 +1803,17 @@ nlm_write_object_contents (abfd) /* The type is 0 for data, 1 for code, 2 for absolute. */ if (bfd_write (&type, sizeof (bfd_byte), 1, abfd) != sizeof (bfd_byte)) - { - bfd_set_error (bfd_error_system_call); - goto error_return; - } + goto error_return; put_word (abfd, offset, temp); if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp)) - { - bfd_set_error (bfd_error_system_call); - goto error_return; - } + goto error_return; len = strlen (sym->name); if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof (bfd_byte)) || bfd_write (sym->name, len, 1, abfd) != len) - { - bfd_set_error (bfd_error_system_call); - goto error_return; - } + goto error_return; } nlm_fixed_header (abfd)->numberOfDebugRecords = c; } @@ -2013,10 +1871,7 @@ nlm_write_object_contents (abfd) nlm_swap_fixed_header_out (abfd, nlm_fixed_header (abfd), fixed_header); if (bfd_write (fixed_header, nlm_fixed_header_size (abfd), 1, abfd) != nlm_fixed_header_size (abfd)) - { - bfd_set_error (bfd_error_system_call); - goto error_return; - } + goto error_return; if (fixed_header != NULL) free (fixed_header); diff --git a/bfd/tekhex.c b/bfd/tekhex.c index cf9af54..ad83c0a 100644 --- a/bfd/tekhex.c +++ b/bfd/tekhex.c @@ -497,7 +497,8 @@ static void boolean eof = false; /* To the front of the file */ - bfd_seek (abfd, (file_ptr) 0, SEEK_SET); + if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) + abort (); while (eof == false) { char buffer[MAXCHUNK]; @@ -516,7 +517,8 @@ static void src++; /* Fetch the type and the length and the checksum */ - bfd_read (src, 1, 5, abfd); + if (bfd_read (src, 1, 5, abfd) != 5) + abort (); /* FIXME */ type = src[2]; @@ -525,7 +527,8 @@ static void chars_on_line = HEX (src) - 5; /* Already read five char */ - bfd_read (src, 1, chars_on_line, abfd); + if (bfd_read (src, 1, chars_on_line, abfd) != chars_on_line) + abort (); /* FIXME */ src[chars_on_line] = 0; /* put a null at the end */ func (abfd, type, src); @@ -592,8 +595,9 @@ tekhex_object_p (abfd) tekhex_init (); - bfd_seek (abfd, (file_ptr) 0, SEEK_SET); - bfd_read (b, 1, 4, abfd); + if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 + || bfd_read (b, 1, 4, abfd) != 4) + return NULL; if (b[0] != '%' || !ISHEX (b[1]) || !ISHEX (b[2]) || !ISHEX (b[3])) return (bfd_target *) NULL; @@ -807,10 +811,11 @@ out (abfd, type, start, end) sum += sum_block[front[2]]; sum += sum_block[front[3]]; /* type */ TOHEX (front + 4, sum); - bfd_write (front, 1, 6, abfd); + if (bfd_write (front, 1, 6, abfd) != 6) + abort (); end[0] = '\n'; - bfd_write (start, 1, end - start + 1, abfd); - + if (bfd_write (start, 1, end - start + 1, abfd) != end - start + 1) + abort (); } static boolean @@ -924,7 +929,8 @@ tekhex_write_object_contents (abfd) } /* And the terminator */ - bfd_write ("%7081010\n", 1, 9, abfd); + if (bfd_write ("%7081010\n", 1, 9, abfd) != 9) + abort (); return true; } |