Print this page
5218 posix definition of NULL
correct unistd.h and iso/stddef_iso.h
update gate source affected

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/tar/tar.c
          +++ new/usr/src/cmd/tar/tar.c
↓ open down ↓ 2638 lines elided ↑ open up ↑
2639 2639   *      convtoreg - determines whether the file should be converted to a
2640 2640   *                  regular file when extracted
2641 2641   *
2642 2642   *      Returns 1 when file size > 0 and typeflag is not recognized
2643 2643   *      Otherwise returns 0
2644 2644   */
2645 2645  static int
2646 2646  convtoreg(off_t size)
2647 2647  {
2648 2648          if ((size > 0) && (dblock.dbuf.typeflag != '0') &&
2649      -            (dblock.dbuf.typeflag != NULL) && (dblock.dbuf.typeflag != '1') &&
     2649 +            (dblock.dbuf.typeflag != '\0') && (dblock.dbuf.typeflag != '1') &&
2650 2650              (dblock.dbuf.typeflag != '2') && (dblock.dbuf.typeflag != '3') &&
2651 2651              (dblock.dbuf.typeflag != '4') && (dblock.dbuf.typeflag != '5') &&
2652 2652              (dblock.dbuf.typeflag != '6') && (dblock.dbuf.typeflag != 'A') &&
2653 2653              (dblock.dbuf.typeflag != 'L') &&
2654 2654              (dblock.dbuf.typeflag != _XATTR_HDRTYPE) &&
2655 2655              (dblock.dbuf.typeflag != 'X')) {
2656 2656                  return (1);
2657 2657          }
2658 2658          return (0);
2659 2659  }
↓ open down ↓ 492 lines elided ↑ open up ↑
3152 3152                          }
3153 3153                          goto filedone;
3154 3154                  }
3155 3155  
3156 3156                  if (dblock.dbuf.typeflag == '6') {      /* FIFO */
3157 3157                          if (rmdir(namep) < 0) {
3158 3158                                  if (errno == ENOTDIR)
3159 3159                                          (void) unlink(namep);
3160 3160                          }
3161 3161                          linkp = templink;
3162      -                        if (*linkp !=  NULL) {
     3162 +                        if (*linkp !=  '\0') {
3163 3163                                  if (Aflag && *linkp == '/')
3164 3164                                          linkp++;
3165 3165                                  if (link(linkp, namep) < 0) {
3166 3166                                          (void) fprintf(stderr, gettext(
3167 3167                                              "tar: %s: cannot link\n"), namep);
3168 3168                                          continue;
3169 3169                                  }
3170 3170                                  if (vflag)
3171 3171                                          (void) fprintf(vfile, gettext(
3172 3172                                              "x %s linked to %s\n"), namep,
↓ open down ↓ 20 lines elided ↑ open up ↑
3193 3193                                              blocks);
3194 3194                          }
3195 3195                          goto filedone;
3196 3196                  }
3197 3197                  if (dblock.dbuf.typeflag == '3' && !Uid) { /* CHAR SPECIAL */
3198 3198                          if (rmdir(namep) < 0) {
3199 3199                                  if (errno == ENOTDIR)
3200 3200                                          (void) unlink(namep);
3201 3201                          }
3202 3202                          linkp = templink;
3203      -                        if (*linkp != NULL) {
     3203 +                        if (*linkp != '\0') {
3204 3204                                  if (Aflag && *linkp == '/')
3205 3205                                          linkp++;
3206 3206                                  if (link(linkp, namep) < 0) {
3207 3207                                          (void) fprintf(stderr, gettext(
3208 3208                                              "tar: %s: cannot link\n"), namep);
3209 3209                                          continue;
3210 3210                                  }
3211 3211                                  if (vflag)
3212 3212                                          (void) fprintf(vfile, gettext(
3213 3213                                              "x %s linked to %s\n"), namep,
↓ open down ↓ 28 lines elided ↑ open up ↑
3242 3242                  }
3243 3243  
3244 3244                  /* BLOCK SPECIAL */
3245 3245  
3246 3246                  if (dblock.dbuf.typeflag == '4' && !Uid) {
3247 3247                          if (rmdir(namep) < 0) {
3248 3248                                  if (errno == ENOTDIR)
3249 3249                                          (void) unlink(namep);
3250 3250                          }
3251 3251                          linkp = templink;
3252      -                        if (*linkp != NULL) {
     3252 +                        if (*linkp != '\0') {
3253 3253                                  if (Aflag && *linkp == '/')
3254 3254                                          linkp++;
3255 3255                                  if (link(linkp, namep) < 0) {
3256 3256                                          (void) fprintf(stderr, gettext(
3257 3257                                              "tar: %s: cannot link\n"), namep);
3258 3258                                          continue;
3259 3259                                  }
3260 3260                                  if (vflag)
3261 3261                                          (void) fprintf(vfile, gettext(
3262 3262                                              "x %s linked to %s\n"), namep,
↓ open down ↓ 119 lines elided ↑ open up ↑
3382 3382                                  done(1);
3383 3383                          } else {
3384 3384                                  (void) fprintf(stderr, gettext(
3385 3385                                      "tar: %s: typeflag '%c' not recognized, "
3386 3386                                      "converting to regular file\n"), namep,
3387 3387                                      dblock.dbuf.typeflag);
3388 3388                                  Errflg = 1;
3389 3389                          }
3390 3390                  }
3391 3391                  if (dblock.dbuf.typeflag == '0' ||
3392      -                    dblock.dbuf.typeflag == NULL || convflag) {
     3392 +                    dblock.dbuf.typeflag == '\0' || convflag) {
3393 3393                          delete_target(dirfd, comp, namep);
3394 3394                          linkp = templink;
3395      -                        if (*linkp != NULL) {
     3395 +                        if (*linkp != '\0') {
3396 3396                                  if (Aflag && *linkp == '/')
3397 3397                                          linkp++;
3398 3398                                  if (link(linkp, comp) < 0) {
3399 3399                                          (void) fprintf(stderr, gettext(
3400 3400                                              "tar: %s: cannot link\n"), namep);
3401 3401                                          continue;
3402 3402                                  }
3403 3403                                  if (vflag)
3404 3404                                          (void) fprintf(vfile, gettext(
3405 3405                                              "x %s linked to %s\n"), comp,
↓ open down ↓ 185 lines elided ↑ open up ↑
3591 3591                          acl_free(aclp);
3592 3592                          aclp = NULL;
3593 3593                  }
3594 3594  
3595 3595                  if (!oflag)
3596 3596                          /* set file ownership */
3597 3597                          resugname(dirfd, comp, symflag);
3598 3598  
3599 3599                  if (pflag && newfile == TRUE && !dir &&
3600 3600                      (dblock.dbuf.typeflag == '0' ||
3601      -                    dblock.dbuf.typeflag == NULL ||
     3601 +                    dblock.dbuf.typeflag == '\0' ||
3602 3602                      convflag || dblock.dbuf.typeflag == '1')) {
3603 3603                          if (fstat(ofile, &xtractbuf) == -1)
3604 3604                                  (void) fprintf(stderr, gettext(
3605 3605                                      "tar: cannot stat extracted file "
3606 3606                                      "%s%s%s%s\n"),
3607 3607                                      (xattrp == NULL) ? "" : (rw_sysattr ?
3608 3608                                      gettext("system attribute ") :
3609 3609                                      gettext("attribute ")),
3610 3610                                      (xattrp == NULL) ? "" : xattrapath,
3611 3611                                      (xattrp == NULL) ? "" :
↓ open down ↓ 1866 lines elided ↑ open up ↑
5478 5478  
5479 5479  static void
5480 5480  add_file_to_table(file_list_t *table[], char *str)
5481 5481  {
5482 5482          char    name[PATH_MAX + 1];
5483 5483          unsigned int h;
5484 5484          file_list_t     *exp;
5485 5485  
5486 5486          (void) strcpy(name, str);
5487 5487          while (name[strlen(name) - 1] == '/') {
5488      -                name[strlen(name) - 1] = NULL;
     5488 +                name[strlen(name) - 1] = '\0';
5489 5489          }
5490 5490  
5491 5491          h = hash(name);
5492 5492          if ((exp = (file_list_t *)calloc(sizeof (file_list_t),
5493 5493              sizeof (char))) == NULL) {
5494 5494                  (void) fprintf(stderr, gettext(
5495 5495                      "tar: out of memory, exclude/include table(entry)\n"));
5496 5496                  exit(1);
5497 5497          }
5498 5498  
↓ open down ↓ 17 lines elided ↑ open up ↑
5516 5516  static int
5517 5517  is_in_table(file_list_t *table[], char *str)
5518 5518  {
5519 5519          char    name[PATH_MAX + 1];
5520 5520          unsigned int    h;
5521 5521          file_list_t     *exp;
5522 5522          char    *ptr;
5523 5523  
5524 5524          (void) strcpy(name, str);
5525 5525          while (name[strlen(name) - 1] == '/') {
5526      -                name[strlen(name) - 1] = NULL;
     5526 +                name[strlen(name) - 1] = '\0';
5527 5527          }
5528 5528  
5529 5529          /*
5530 5530           * check for the file name in the passed list
5531 5531           */
5532 5532          h = hash(name);
5533 5533          exp = table[h];
5534 5534          while (exp != NULL) {
5535 5535                  if (strcmp(name, exp->name) == 0) {
5536 5536                          return (1);
5537 5537                  }
5538 5538                  exp = exp->next;
5539 5539          }
5540 5540  
5541 5541          /*
5542 5542           * check for any parent directories in the file list
5543 5543           */
5544 5544          while ((ptr = strrchr(name, '/'))) {
5545      -                *ptr = NULL;
     5545 +                *ptr = '\0';
5546 5546                  h = hash(name);
5547 5547                  exp = table[h];
5548 5548                  while (exp != NULL) {
5549 5549                          if (strcmp(name, exp->name) == 0) {
5550 5550                                  return (1);
5551 5551                          }
5552 5552                          exp = exp->next;
5553 5553                  }
5554 5554          }
5555 5555  
↓ open down ↓ 1052 lines elided ↑ open up ↑
6608 6608  
6609 6609          if (unlinkat(fd, comp, AT_REMOVEDIR) < 0) {
6610 6610                  if (errno == ENOTDIR && !hflag) {
6611 6611                          (void) unlinkat(fd, comp, 0);
6612 6612                  } else if (errno == ENOTDIR && hflag) {
6613 6613                          if (!lstat(namep, &xtractbuf)) {
6614 6614                                  if ((xtractbuf.st_mode & S_IFMT) != S_IFLNK) {
6615 6615                                          (void) unlinkat(fd, comp, 0);
6616 6616                                  } else if ((n = readlink(namep, buf,
6617 6617                                      PATH_MAX)) != -1) {
6618      -                                        buf[n] = (char)NULL;
     6618 +                                        buf[n] = '\0';
6619 6619                                          (void) unlinkat(fd, buf,
6620 6620                                              AT_REMOVEDIR);
6621 6621                                          if (errno == ENOTDIR)
6622 6622                                                  (void) unlinkat(fd, buf, 0);
6623 6623                                  } else {
6624 6624                                          (void) unlinkat(fd, comp, 0);
6625 6625                                  }
6626 6626                          } else {
6627 6627                                  (void) unlinkat(fd, comp, 0);
6628 6628                          }
↓ open down ↓ 2848 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX