home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume3 / pathalias2 / bug next >
Encoding:
Text File  |  1986-11-30  |  1.5 KB  |  48 lines

  1. /* Written 11:53 pm  Aug 11, 1986 by john@uw-nsr.UUCP in mirror:net.bugs */
  2. /* ---------- "Bug in "pathalias"" ---------- */
  3. The version of "pathalias" posted to mod.sources seems to contain a bug.
  4. From the "CHANGES" file it seems that we have the version distributed
  5. on or about 1/86.  
  6.  
  7. The bug concerns the function yylex() as contained in file "parse.y".
  8. Within the body of yylex() there is a declaration of the variable
  9. "buf" as follows:
  10.  
  11.     char    buf[BUFSIZ], errbuf[128];
  12.  
  13. Unfortunately, the value contained in buf is used after the function
  14. has returned.  For example, when a HOST token has been scanned the 
  15. following code is executed: 
  16.  
  17.             .
  18.                 .
  19.             .
  20.  
  21.         yylval.y_name = buf;
  22.         return(HOST);
  23.     }
  24.  
  25. Of course, as soon as the return statement is executed the value of
  26. buf is no longer guaranteed.  On many implementations this "happens"
  27. to work, but it is not correct.
  28.  
  29. While this was tedious to find, it is easy to fix.  Simply change the
  30. old declaration to the following:
  31.  
  32.     #if 0    /* bug fix */
  33.         char    buf[BUFSIZ], errbuf[128];
  34.     #else
  35.         static    char    buf[BUFSIZ];
  36.             char    errbuf[128];
  37.     #endif
  38.  
  39. After fixing this one minor problem "pathalias" works like a champ.  I 
  40. should point out that very few programs have been as easy to port to our
  41. system.  We have a DG MV/10000 and we find all the "dereference through 
  42. NULL" bugs and then some :-)
  43. -- 
  44. John Sambrook                Work: (206) 545-2018
  45. University of Washington WD-12        Home: (206) 487-0180
  46. Seattle, Washington  98195        UUCP: uw-beaver!uw-nsr!john
  47. /* End of text from mirror:net.bugs */
  48.