Fix the termination of the readlink result
authorPeter Hutterer <peter.hutterer@who-t.net>
Tue, 10 Nov 2020 04:25:31 +0000 (14:25 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 10 Nov 2020 04:27:22 +0000 (14:27 +1000)
nread is the number of bytes put into the buffer, let's terminate it there
instead of one byte over. This only worked because execdir was initialized to
zero.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/builddir.h

index bc0c9e5473da2929e3399e9674c1f52629fc4ab5..19825759a5193aebb6d694a6bb05103ac1865bd3 100644 (file)
@@ -50,7 +50,7 @@ builddir_lookup(void)
 
        /* readlink doesn't terminate the string and readlink says
           anything past sz is undefined */
-       execdir[++nread] = '\0';
+       execdir[nread] = '\0';
 
        pathsep = strrchr(execdir, '/');
        if (!pathsep)