Revision: 75922
          http://sourceforge.net/p/brlcad/code/75922
Author:   starseeker
Date:     2020-05-25 18:11:24 +0000 (Mon, 25 May 2020)
Log Message:
-----------
Make sure the readlink return is NULL terminated

Modified Paths:
--------------
    brlcad/trunk/src/libbu/realpath_bsd.c

Modified: brlcad/trunk/src/libbu/realpath_bsd.c
===================================================================
--- brlcad/trunk/src/libbu/realpath_bsd.c       2020-05-25 17:35:07 UTC (rev 
75921)
+++ brlcad/trunk/src/libbu/realpath_bsd.c       2020-05-25 18:11:24 UTC (rev 
75922)
@@ -165,7 +165,11 @@
            errno = ENAMETOOLONG;
            goto err;
        }
-       slen = readlink(resolved, symlink, sizeof(symlink));
+       slen = readlink(resolved, symlink, sizeof(symlink) - 1);
+       /* POS30-C: ensure NULL termination of readlink */
+       if (len >= 0) {
+           symlink[slen] = '\0';
+       }
        if (slen < 0) {
            switch (errno) {
                case EINVAL:

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to