home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / next / bugs / 5 < prev    next >
Encoding:
Text File  |  1992-12-27  |  1.2 KB  |  51 lines

  1. Path: sparky!uunet!ogicse!news.u.washington.edu!stein.u.washington.edu!bungi
  2. From: bungi@stein.u.washington.edu (Timothy J. Wood)
  3. Newsgroups: comp.sys.next.bugs
  4. Subject: Bug in the realpath(3) function
  5. Message-ID: <1992Dec27.101753.16648@u.washington.edu>
  6. Date: 27 Dec 92 10:17:53 GMT
  7. Article-I.D.: u.1992Dec27.101753.16648
  8. Sender: news@u.washington.edu (USENET News System)
  9. Organization: University of Washington
  10. Lines: 39
  11.  
  12.  
  13.   I believe that the following code exhibits a bug in the NeXT
  14.   implementation of the realpath(3) function.  I am running NS3.0.
  15.  
  16. #import <sys/param.h>
  17. #import <stdio.h>
  18.  
  19. /*
  20.  * usage: realpath [filelist]
  21.  */
  22.  
  23. int main (int argc, char *argv[])
  24. {
  25.         char *file_name;
  26.         char resolved_name[MAXPATHLEN];
  27.         int i = 1;
  28.  
  29.         while (i < argc) {
  30.                 if (!realpath(argv[i], resolved_name))
  31.                         perror(argv[i]);
  32.                 else
  33.                         puts(resolved_name);
  34.                 i++;
  35.         }
  36. }
  37.  
  38.  
  39.    The problem involves the clipping of the prefix of some paths, for
  40.    example:
  41.  
  42. % cd /
  43. % realpath tmp
  44. rivate/tmp
  45. % realpath /tmp
  46. /private/tmp
  47. %
  48.  
  49.   Notice that in the first case the leading "/p" was stripped from the
  50.   output.  This happens in various other cases as well.
  51.