~vcs-imports/make/master

« back to all changes in this revision

Viewing changes to src/arscan.c

  • Committer: Paul Smith
  • Date: 2022-06-04 22:34:15 UTC
  • Revision ID: git-v1:e4b7ac21dc1663de1d901cda0b395d819b5c08ab
* src/misc.c (make_toui): Parse a string into an unsigned int

* src/makeint.h: Declare it.
* src/arscan.c (ar_scan): Replace atoi() calls with make_toui().
Modify some integral types to be more correct.
* src/job.c (load_too_high): Replace atoi() calls with make_toui().
* src/main.c (main): Ditto.
(decode_switches): Ditto.

Show diffs side-by-side

added added

removed removed

Lines of Context:
441
441
# endif
442
442
#endif
443
443
  char *namemap = 0;
444
 
  int namemap_size = 0;
 
444
  unsigned int namemap_size = 0;
445
445
  int desc = open (archive, O_RDONLY, 0);
446
446
  if (desc < 0)
447
447
    return -1;
541
541
 
542
542
    while (1)
543
543
      {
544
 
        int nread;
 
544
        ssize_t nread;
545
545
        struct ar_hdr member_header;
546
546
#ifdef AIAMAGBIG
547
547
        struct ar_hdr_big member_header_big;
696
696
              && (name[0] == ' ' || name[0] == '/')
697
697
              && namemap != 0)
698
698
            {
699
 
              int name_off = atoi (name + 1);
700
 
              int name_len;
 
699
              const char* err;
 
700
              unsigned int name_off = make_toui (name + 1, &err);
 
701
              size_t name_len;
701
702
 
702
 
              if (name_off < 0 || name_off >= namemap_size)
 
703
              if (err|| name_off >= namemap_size)
703
704
                goto invalid;
704
705
 
705
706
              name = namemap + name_off;
712
713
                   && name[1] == '1'
713
714
                   && name[2] == '/')
714
715
            {
715
 
              int name_len = atoi (name + 3);
 
716
              const char* err;
 
717
              unsigned int name_len = make_toui (name + 3, &err);
716
718
 
717
 
              if (name_len < 1)
 
719
              if (err || name_len == 0 || name_len > PATH_MAX)
718
720
                goto invalid;
719
721
 
720
722
              name = alloca (name_len + 1);