From: Peter Hutterer Date: Tue, 10 Nov 2020 04:25:31 +0000 (+1000) Subject: Fix the termination of the readlink result X-Git-Tag: 1.16.4~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dc1edd140f10b459626d903382df28c74672739b;p=platform%2Fupstream%2Flibinput.git Fix the termination of the readlink result 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 (cherry picked from commit 34fe17f72353b5fe65724390e4ec384ec848499a) --- diff --git a/src/builddir.h b/src/builddir.h index bc0c9e54..19825759 100644 --- a/src/builddir.h +++ b/src/builddir.h @@ -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)