[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.21 and 1.24.6.2

version 1.21, 1999/08/10 13:03:11 version 1.24.6.2, 2002/11/11 22:22:09
Line 49  __RCSID("$NetBSD$");
Line 49  __RCSID("$NetBSD$");
 #include <sys/param.h>  #include <sys/param.h>
 #include <sys/stat.h>  #include <sys/stat.h>
   
   #include <assert.h>
 #include <dirent.h>  #include <dirent.h>
 #include <errno.h>  #include <errno.h>
 #include <fcntl.h>  #include <fcntl.h>
Line 60  __RCSID("$NetBSD$");
Line 61  __RCSID("$NetBSD$");
 #include "extern.h"  #include "extern.h"
   
 #ifdef __weak_alias  #ifdef __weak_alias
 __weak_alias(getcwd,_getcwd);  __weak_alias(getcwd,_getcwd)
 __weak_alias(realpath,_realpath);  __weak_alias(realpath,_realpath)
 #endif  #endif
   
 #define ISDOT(dp) \  #define ISDOT(dp) \
Line 89  realpath(path, resolved)
Line 90  realpath(path, resolved)
         int fd, n, rootd, serrno, nlnk = 0;          int fd, n, rootd, serrno, nlnk = 0;
         char *p, *q, wbuf[MAXPATHLEN];          char *p, *q, wbuf[MAXPATHLEN];
   
           _DIAGASSERT(path != NULL);
           _DIAGASSERT(resolved != NULL);
   
         /* Save the starting point. */          /* Save the starting point. */
         if ((fd = open(".", O_RDONLY)) < 0) {          if ((fd = open(".", O_RDONLY)) < 0) {
                 (void)strcpy(resolved, ".");                  (void)strcpy(resolved, ".");
Line 130  loop:
Line 134  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 147  loop:
Line 151  loop:
          * Save the last component name and get the full pathname of           * Save the last component name and get the full pathname of
          * the current directory.           * the current directory.
          */           */
         (void)strncpy(wbuf, p, (sizeof(wbuf) - 1));          (void)strlcpy(wbuf, p, sizeof(wbuf));
   
         /*          /*
          * Call the inernal internal version of getcwd which           * Call the inernal internal version of getcwd which

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.24.6.2

CVSweb <webmaster@jp.NetBSD.org>