From 39538c4bb94fb3a6a39719054b78a55542e5cc2f Mon Sep 17 00:00:00 2001 From: kanurag94 Date: Sat, 16 May 2020 15:05:21 +0530 Subject: [PATCH 1/2] Fix Buffer Overflow issue#152 --- src/util/xstdio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/xstdio.cpp b/src/util/xstdio.cpp index 2bcbe8e1..2bd38119 100644 --- a/src/util/xstdio.cpp +++ b/src/util/xstdio.cpp @@ -111,7 +111,7 @@ xio_path xio_getdirectory(xio_constpath filename) xio_path xio_getfilename(const char *basename, const char *extension) { - static char name[40]; + static char name[80]; int nimage = 0; struct stat sb; char *base = xio_fixpath(basename); From bc6ebf67989356d271666a048107370fbf0e4ab6 Mon Sep 17 00:00:00 2001 From: kanurag94 Date: Sat, 16 May 2020 16:27:31 +0530 Subject: [PATCH 2/2] Use dynamic filepath allocation --- src/util/xstdio.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/xstdio.cpp b/src/util/xstdio.cpp index 2bd38119..e1c62d68 100644 --- a/src/util/xstdio.cpp +++ b/src/util/xstdio.cpp @@ -111,7 +111,9 @@ xio_path xio_getdirectory(xio_constpath filename) xio_path xio_getfilename(const char *basename, const char *extension) { - static char name[80]; + int pathlength = sizeof(basename) + sizeof(extension); + static char* name; + name = (char* )malloc(pathlength * sizeof (char)); int nimage = 0; struct stat sb; char *base = xio_fixpath(basename);