=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ctfdump/ctfdump.c,v retrieving revision 1.26 retrieving revision 1.27 diff -c -r1.26 -r1.27 *** src/usr.bin/ctfdump/ctfdump.c 2022/08/10 07:58:04 1.26 --- src/usr.bin/ctfdump/ctfdump.c 2022/08/14 15:01:18 1.27 *************** *** 1,4 **** ! /* $OpenBSD: ctfdump.c,v 1.26 2022/08/10 07:58:04 tb Exp $ */ /* * Copyright (c) 2016 Martin Pieuchot --- 1,4 ---- ! /* $OpenBSD: ctfdump.c,v 1.27 2022/08/14 15:01:18 millert Exp $ */ /* * Copyright (c) 2016 Martin Pieuchot *************** *** 53,67 **** __dead void usage(void); int ctf_dump(const char *, size_t, uint8_t); ! void ctf_dump_type(struct ctf_header *, const char *, off_t, uint32_t, uint32_t *, uint32_t); const char *ctf_kind2name(uint16_t); const char *ctf_enc2name(uint16_t); const char *ctf_fpenc2name(uint16_t); ! const char *ctf_off2name(struct ctf_header *, const char *, off_t, uint32_t); ! char *decompress(const char *, size_t, off_t); int elf_dump(uint8_t); const char *elf_idx2sym(size_t *, uint8_t); --- 53,67 ---- __dead void usage(void); int ctf_dump(const char *, size_t, uint8_t); ! void ctf_dump_type(struct ctf_header *, const char *, size_t, uint32_t, uint32_t *, uint32_t); const char *ctf_kind2name(uint16_t); const char *ctf_enc2name(uint16_t); const char *ctf_fpenc2name(uint16_t); ! const char *ctf_off2name(struct ctf_header *, const char *, size_t, uint32_t); ! char *decompress(const char *, size_t, size_t); int elf_dump(uint8_t); const char *elf_idx2sym(size_t *, uint8_t); *************** *** 274,280 **** isctf(const char *p, size_t filesize) { struct ctf_header cth; ! off_t dlen; if (filesize < sizeof(struct ctf_header)) { warnx("file too small to be CTF"); --- 274,280 ---- isctf(const char *p, size_t filesize) { struct ctf_header cth; ! size_t dlen; if (filesize < sizeof(struct ctf_header)) { warnx("file too small to be CTF"); *************** *** 285,292 **** if (cth.cth_magic != CTF_MAGIC || cth.cth_version != CTF_VERSION) return 0; ! dlen = (off_t)cth.cth_stroff + cth.cth_strlen; ! if (dlen > (off_t)filesize && !(cth.cth_flags & CTF_F_COMPRESS)) { warnx("bogus file size"); return 0; } --- 285,292 ---- if (cth.cth_magic != CTF_MAGIC || cth.cth_version != CTF_VERSION) return 0; ! dlen = cth.cth_stroff + cth.cth_strlen; ! if (dlen > filesize && !(cth.cth_flags & CTF_F_COMPRESS)) { warnx("bogus file size"); return 0; } *************** *** 318,328 **** ctf_dump(const char *p, size_t size, uint8_t flags) { struct ctf_header cth; ! off_t dlen; char *data; memcpy(&cth, p, sizeof(struct ctf_header)); ! dlen = (off_t)cth.cth_stroff + cth.cth_strlen; if (cth.cth_flags & CTF_F_COMPRESS) { data = decompress(p + sizeof(cth), size - sizeof(cth), dlen); if (data == NULL) --- 318,328 ---- ctf_dump(const char *p, size_t size, uint8_t flags) { struct ctf_header cth; ! size_t dlen; char *data; memcpy(&cth, p, sizeof(struct ctf_header)); ! dlen = cth.cth_stroff + cth.cth_strlen; if (cth.cth_flags & CTF_F_COMPRESS) { data = decompress(p + sizeof(cth), size - sizeof(cth), dlen); if (data == NULL) *************** *** 451,457 **** } void ! ctf_dump_type(struct ctf_header *cth, const char *data, off_t dlen, uint32_t stroff, uint32_t *offset, uint32_t idx) { const char *p = data + *offset; --- 451,457 ---- } void ! ctf_dump_type(struct ctf_header *cth, const char *data, size_t dlen, uint32_t stroff, uint32_t *offset, uint32_t idx) { const char *p = data + *offset; *************** *** 642,648 **** } const char * ! ctf_off2name(struct ctf_header *cth, const char *data, off_t dlen, uint32_t offset) { const char *name; --- 642,648 ---- } const char * ! ctf_off2name(struct ctf_header *cth, const char *data, size_t dlen, uint32_t offset) { const char *name; *************** *** 664,670 **** } char * ! decompress(const char *buf, size_t size, off_t len) { #ifdef ZLIB z_stream stream; --- 664,670 ---- } char * ! decompress(const char *buf, size_t size, size_t len) { #ifdef ZLIB z_stream stream; *************** *** 699,706 **** goto exit; } ! if (len < 0 || (uintmax_t)stream.total_out != (uintmax_t)len) { ! warnx("decompression failed: %lu != %lld", stream.total_out, len); goto exit; } --- 699,706 ---- goto exit; } ! if (stream.total_out != len) { ! warnx("decompression failed: %lu != %zu", stream.total_out, len); goto exit; }