From 3d8d271595f0edc8a734f3cec6f034f9f5779f8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Thu, 27 Aug 2020 07:38:26 +0700 Subject: [PATCH] GetInstallDir: fix buffer overflow strlen(3) will return length of input, not including terminating NUL character. And strcpy(3) will copy the included NUL character. Thus, we'll get buffer overflow for 1 character. Fix it. --- src/shared.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared.c b/src/shared.c index 17386509..4c1ce315 100644 --- a/src/shared.c +++ b/src/shared.c @@ -107,7 +107,7 @@ char *xavaGetInstallDir() { path[strlen(path)-executableNameSize] = '\0'; #else // everything non-windows is simple as fuck, go look at the mess above - const char *path = malloc(strlen(PREFIX"/share/"PACKAGE"/")); + const char *path = malloc(strlen(PREFIX"/share/"PACKAGE"/") + 1); strcpy(path, PREFIX"/share/"PACKAGE"/"); #endif return path;