Re: [clisp:clisp] New commit [b83c12] by Sam Steingold

Bruno Haible <[email protected]> Sat, 27 Jan 2018 11:50:16 +0100
Newsgroups gmane.lisp.clisp.devel
Message-ID <1921068.iQjUKh0KmW@omega>
Hi Sam,

> src/pathname.d (my_realpath): Cosmetic change to avoid gcc warning
> 
> "suggest a space before ';' or explicit braces around empty body in 'while' statement".
> 
> By Sam Steingold on 01/22/2018 16:17
> [**View Changes**](https://sourceforge.net/p/clisp/clisp/ci/b83c1201abb01c8dab13de6e3bb70bff35682243/)

This part:

@@ -186,14 +186,13 @@
                     if (mypath_ptr < mypath_limit) { *mypath_ptr++ = '/'; } /* first, append a '/' */
                     /* then the rest: */
                     while ((mypath_ptr <= mypath_limit)
-                           && (*mypath_ptr = *from_ptr++))
-                      { mypath_ptr++; }
+                           && (*mypath_ptr++ = *from_ptr++)) ;
                     *mypath_ptr = 0; /* and conclude wit 0 */
                   }
                   /* this replaces resp. completes the path: */

Is not right. The value of mypath_ptr after the loop matters. Your patch
has the effect of terminating mypath with 2 NUL bytes instead of 1 NUL byte.
Thus causing a buffer overrun.

Bruno


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
clisp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-devel