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

Diff for /src/usr.bin/skeyinit/skeyinit.c between version 1.51 and 1.52

version 1.51, 2005/07/06 22:15:11 version 1.52, 2013/11/28 18:24:55
Line 64 
Line 64 
         if (gethostname(hostname, sizeof(hostname)) < 0)          if (gethostname(hostname, sizeof(hostname)) < 0)
                 err(1, "gethostname");                  err(1, "gethostname");
         for (i = 0, p = seed; hostname[i] && i < SKEY_NAMELEN; i++) {          for (i = 0, p = seed; hostname[i] && i < SKEY_NAMELEN; i++) {
                 if (isalpha(hostname[i])) {                  if (isalpha((unsigned char)hostname[i])) {
                         if (isupper(hostname[i]))                          if (isupper((unsigned char)hostname[i]))
                                 hostname[i] = tolower(hostname[i]);                                  hostname[i] = tolower((unsigned char)hostname[i]);
                         *p++ = hostname[i];                          *p++ = hostname[i];
                 } else if (isdigit(hostname[i]))                  } else if (isdigit((unsigned char)hostname[i]))
                         *p++ = hostname[i];                          *p++ = hostname[i];
         }          }
         noise = arc4random();          noise = arc4random();
Line 241 
Line 241 
                          */                           */
                         l = strlen(skey.seed);                          l = strlen(skey.seed);
                         for (p = skey.seed; *p; p++) {                          for (p = skey.seed; *p; p++) {
                                 if (isalpha(*p)) {                                  if (isalpha((unsigned char)*p)) {
                                         if (isupper(*p))                                          if (isupper((unsigned char)*p))
                                                 *p = tolower(*p);                                                  *p = tolower((unsigned char)*p);
                                 } else if (!isdigit(*p)) {                                  } else if (!isdigit((unsigned char)*p)) {
                                         memmove(p, p + 1, l - (p - skey.seed));                                          memmove(p, p + 1, l - (p - skey.seed));
                                         l--;                                          l--;
                                 }                                  }
Line 253 
Line 253 
                         /* If the seed ends in 0-8 just add one.  */                          /* If the seed ends in 0-8 just add one.  */
                         if (l > 0) {                          if (l > 0) {
                                 lastc = skey.seed[l - 1];                                  lastc = skey.seed[l - 1];
                                 if (isdigit(lastc) && lastc != '9') {                                  if (isdigit((unsigned char)lastc) &&
                                       lastc != '9') {
                                         (void)strlcpy(seed, skey.seed,                                          (void)strlcpy(seed, skey.seed,
                                             sizeof seed);                                              sizeof seed);
                                         seed[l - 1] = lastc + 1;                                          seed[l - 1] = lastc + 1;
                                 }                                  }
                                 if (isdigit(lastc) && lastc == '9' && l < 16) {                                  if (isdigit((unsigned char)lastc) &&
                                       lastc == '9' && l < 16) {
                                         (void)strlcpy(seed, skey.seed,                                          (void)strlcpy(seed, skey.seed,
                                             sizeof seed);                                              sizeof seed);
                                         seed[l - 1] = '0';                                          seed[l - 1] = '0';
Line 356 
Line 358 
                         continue;                          continue;
                 }                  }
                 for (p = newseed; *p; p++) {                  for (p = newseed; *p; p++) {
                         if (isspace(*p)) {                          if (isspace((unsigned char)*p)) {
                                 (void)fputs("ERROR: Seed must not contain "                                  (void)fputs("ERROR: Seed must not contain "
                                     "any spaces\n", stderr);                                      "any spaces\n", stderr);
                                 break;                                  break;
                         } else if (isalpha(*p)) {                          } else if (isalpha((unsigned char)*p)) {
                                 if (isupper(*p))                                  if (isupper((unsigned char)*p))
                                         *p = tolower(*p);                                          *p = tolower((unsigned char)*p);
                         } else if (!isdigit(*p)) {                          } else if (!isdigit((unsigned char)*p)) {
                                 (void)fputs("ERROR: Seed must be purely "                                  (void)fputs("ERROR: Seed must be purely "
                                     "alphanumeric\n", stderr);                                      "alphanumeric\n", stderr);
                                 break;                                  break;
Line 511 
Line 513 
                         continue;                          continue;
                 if ((cp = strtok(NULL, " \t")) == NULL)                  if ((cp = strtok(NULL, " \t")) == NULL)
                         continue;                          continue;
                 if (isalpha(*cp)) {                  if (isalpha((unsigned char)*cp)) {
                         hashtype = cp;                          hashtype = cp;
                         if ((cp = strtok(NULL, " \t")) == NULL)                          if ((cp = strtok(NULL, " \t")) == NULL)
                                 continue;                                  continue;

Legend:
Removed from v.1.51  
changed lines
  Added in v.1.52