[BACK]Return to ctfdump.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ctfdump

Diff for /src/usr.bin/ctfdump/ctfdump.c between version 1.26 and 1.27

version 1.26, 2022/08/10 07:58:04 version 1.27, 2022/08/14 15:01:18
Line 53 
Line 53 
 __dead void      usage(void);  __dead void      usage(void);
   
 int              ctf_dump(const char *, size_t, uint8_t);  int              ctf_dump(const char *, size_t, uint8_t);
 void             ctf_dump_type(struct ctf_header *, const char *, off_t,  void             ctf_dump_type(struct ctf_header *, const char *, size_t,
                      uint32_t, uint32_t *, uint32_t);                       uint32_t, uint32_t *, uint32_t);
 const char      *ctf_kind2name(uint16_t);  const char      *ctf_kind2name(uint16_t);
 const char      *ctf_enc2name(uint16_t);  const char      *ctf_enc2name(uint16_t);
 const char      *ctf_fpenc2name(uint16_t);  const char      *ctf_fpenc2name(uint16_t);
 const char      *ctf_off2name(struct ctf_header *, const char *, off_t,  const char      *ctf_off2name(struct ctf_header *, const char *, size_t,
                      uint32_t);                       uint32_t);
   
 char            *decompress(const char *, size_t, off_t);  char            *decompress(const char *, size_t, size_t);
 int              elf_dump(uint8_t);  int              elf_dump(uint8_t);
 const char      *elf_idx2sym(size_t *, uint8_t);  const char      *elf_idx2sym(size_t *, uint8_t);
   
Line 274 
Line 274 
 isctf(const char *p, size_t filesize)  isctf(const char *p, size_t filesize)
 {  {
         struct ctf_header        cth;          struct ctf_header        cth;
         off_t                    dlen;          size_t                   dlen;
   
         if (filesize < sizeof(struct ctf_header)) {          if (filesize < sizeof(struct ctf_header)) {
                 warnx("file too small to be CTF");                  warnx("file too small to be CTF");
Line 285 
Line 285 
         if (cth.cth_magic != CTF_MAGIC || cth.cth_version != CTF_VERSION)          if (cth.cth_magic != CTF_MAGIC || cth.cth_version != CTF_VERSION)
                 return 0;                  return 0;
   
         dlen = (off_t)cth.cth_stroff + cth.cth_strlen;          dlen = cth.cth_stroff + cth.cth_strlen;
         if (dlen > (off_t)filesize && !(cth.cth_flags & CTF_F_COMPRESS)) {          if (dlen > filesize && !(cth.cth_flags & CTF_F_COMPRESS)) {
                 warnx("bogus file size");                  warnx("bogus file size");
                 return 0;                  return 0;
         }          }
Line 318 
Line 318 
 ctf_dump(const char *p, size_t size, uint8_t flags)  ctf_dump(const char *p, size_t size, uint8_t flags)
 {  {
         struct ctf_header        cth;          struct ctf_header        cth;
         off_t                    dlen;          size_t                   dlen;
         char                    *data;          char                    *data;
   
         memcpy(&cth, p, sizeof(struct ctf_header));          memcpy(&cth, p, sizeof(struct ctf_header));
         dlen = (off_t)cth.cth_stroff + cth.cth_strlen;          dlen = cth.cth_stroff + cth.cth_strlen;
         if (cth.cth_flags & CTF_F_COMPRESS) {          if (cth.cth_flags & CTF_F_COMPRESS) {
                 data = decompress(p + sizeof(cth), size - sizeof(cth), dlen);                  data = decompress(p + sizeof(cth), size - sizeof(cth), dlen);
                 if (data == NULL)                  if (data == NULL)
Line 451 
Line 451 
 }  }
   
 void  void
 ctf_dump_type(struct ctf_header *cth, const char *data, off_t dlen,  ctf_dump_type(struct ctf_header *cth, const char *data, size_t dlen,
     uint32_t stroff, uint32_t *offset, uint32_t idx)      uint32_t stroff, uint32_t *offset, uint32_t idx)
 {  {
         const char              *p = data + *offset;          const char              *p = data + *offset;
Line 642 
Line 642 
 }  }
   
 const char *  const char *
 ctf_off2name(struct ctf_header *cth, const char *data, off_t dlen,  ctf_off2name(struct ctf_header *cth, const char *data, size_t dlen,
     uint32_t offset)      uint32_t offset)
 {  {
         const char              *name;          const char              *name;
Line 664 
Line 664 
 }  }
   
 char *  char *
 decompress(const char *buf, size_t size, off_t len)  decompress(const char *buf, size_t size, size_t len)
 {  {
 #ifdef ZLIB  #ifdef ZLIB
         z_stream                 stream;          z_stream                 stream;
Line 699 
Line 699 
                 goto exit;                  goto exit;
         }          }
   
         if (len < 0 || (uintmax_t)stream.total_out != (uintmax_t)len) {          if (stream.total_out != len) {
                 warnx("decompression failed: %lu != %lld",                  warnx("decompression failed: %lu != %zu",
                     stream.total_out, len);                      stream.total_out, len);
                 goto exit;                  goto exit;
         }          }

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.27