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

Diff for /src/usr.bin/mg/fileio.c between version 1.87 and 1.88

version 1.87, 2012/04/12 04:47:59 version 1.88, 2012/05/23 05:29:22
Line 270 
Line 270 
 char *  char *
 adjustname(const char *fn, int slashslash)  adjustname(const char *fn, int slashslash)
 {  {
           struct stat      statbuf;
         static char      fnb[MAXPATHLEN];          static char      fnb[MAXPATHLEN];
         const char      *cp, *ep = NULL;          const char      *cp, *ep = NULL;
         char             user[LOGIN_NAME_MAX], path[MAXPATHLEN];          char             user[LOGIN_NAME_MAX], path[MAXPATHLEN];
Line 291 
Line 292 
                 }                  }
         }          }
   
         /* first handle tilde expansion */          /*
         if (fn[0] == '~') {           * Next, expand file names beginning with '~', if appropriate:
            *   1, if ./~fn exists, continue without expanding tilde.
            *   2, otherwise, if username 'fn' exists, expand tilde with home
            *      directory path.
            *   3, otherwise, continue and create new buffer called ~fn.
            */
           if (fn[0] == '~' && stat(fn, &statbuf) != 0) {
                 struct passwd *pw;                  struct passwd *pw;
   
                 cp = strchr(fn, '/');                  cp = strchr(fn, '/');
Line 310 
Line 317 
                         user[ulen] = '\0';                          user[ulen] = '\0';
                 }                  }
                 pw = getpwnam(user);                  pw = getpwnam(user);
                 if (pw == NULL) {                  if (pw != NULL) {
                         ewprintf("Unknown user %s", user);                          plen = strlcpy(path, pw->pw_dir, sizeof(path));
                         return (NULL);                          if (plen == 0 || path[plen - 1] != '/') {
                 }                                  if (strlcat(path, "/", sizeof(path)) >=
                 plen = strlcpy(path, pw->pw_dir, sizeof(path));                                      sizeof(path)) {
                 if (plen == 0 || path[plen - 1] != '/') {                                          ewprintf("Path too long");
                         if (strlcat(path, "/", sizeof(path)) >= sizeof(path)) {                                          return (NULL);
                                 ewprintf("Path too long");                                  }
                                 return (NULL);  
                         }                          }
                           fn = cp;
                           if (*fn == '/')
                                   fn++;
                 }                  }
                 fn = cp;  
                 if (*fn == '/')  
                         fn++;  
         }          }
         if (strlcat(path, fn, sizeof(path)) >= sizeof(path)) {          if (strlcat(path, fn, sizeof(path)) >= sizeof(path)) {
                 ewprintf("Path too long");                  ewprintf("Path too long");

Legend:
Removed from v.1.87  
changed lines
  Added in v.1.88