[BACK]Return to getcwd.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libc / gen

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/lib/libc/gen/getcwd.c between version 1.24.6.1 and 1.29

version 1.24.6.1, 2002/04/25 04:01:41 version 1.29, 2003/08/03 04:12:01
Line 95  realpath(path, resolved)
Line 95  realpath(path, resolved)
   
         /* Save the starting point. */          /* Save the starting point. */
         if ((fd = open(".", O_RDONLY)) < 0) {          if ((fd = open(".", O_RDONLY)) < 0) {
                 (void)strcpy(resolved, ".");                  (void)strlcpy(resolved, ".", MAXPATHLEN);
                 return (NULL);                  return (NULL);
         }          }
   
Line 107  realpath(path, resolved)
Line 107  realpath(path, resolved)
          *     if it is a directory, then change to that directory.           *     if it is a directory, then change to that directory.
          * get the current directory name and append the basename.           * get the current directory name and append the basename.
          */           */
         (void)strncpy(resolved, path, MAXPATHLEN - 1);          (void)strlcpy(resolved, path, MAXPATHLEN);
         resolved[MAXPATHLEN - 1] = '\0';  
 loop:  loop:
         q = strrchr(resolved, '/');          q = strrchr(resolved, '/');
         if (q != NULL) {          if (q != NULL) {
Line 134  loop:
Line 133  loop:
                                 errno = ELOOP;                                  errno = ELOOP;
                                 goto err1;                                  goto err1;
                         }                          }
                         n = readlink(p, resolved, MAXPATHLEN);                          n = readlink(p, resolved, MAXPATHLEN-1);
                         if (n < 0)                          if (n < 0)
                                 goto err1;                                  goto err1;
                         resolved[n] = '\0';                          resolved[n] = '\0';
Line 170  loop:
Line 169  loop:
                 rootd = 0;                  rootd = 0;
   
         if (*wbuf) {          if (*wbuf) {
                 if (strlen(resolved) + strlen(wbuf) + rootd + 1 > MAXPATHLEN) {                  if (strlen(resolved) + strlen(wbuf) + (rootd ? 0 : 1) + 1 >
                       MAXPATHLEN) {
                         errno = ENAMETOOLONG;                          errno = ENAMETOOLONG;
                         goto err1;                          goto err1;
                 }                  }

Legend:
Removed from v.1.24.6.1  
changed lines
  Added in v.1.29

CVSweb <webmaster@jp.NetBSD.org>