summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2016-04-01 08:30:12 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2016-04-01 08:31:43 +0200
commitdd242e1ab71cb1b63b9cf9d56d93b5a6839b8777 (patch)
treed01c80bcf971395828af45e94a2d70a91b2a97df
parent65a61050376390c2bd702b22e8e12c934db9664c (diff)
Fix `exename` buffer overflow
Avoid a possible buffer overflow by storing the pointer (which is guaranteed to be in memory for the run of the application) instead of copying the value.
-rw-r--r--src/help.c2
-rw-r--r--src/main.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/help.c b/src/help.c
index 5357136..df4665c 100644
--- a/src/help.c
+++ b/src/help.c
@@ -37,7 +37,7 @@ int load_help () {
// last change to read the help file !
if (! f ) {
char cwd[PATH_MAX];
- extern char exepath[];
+ extern char *exepath;
if (realpath(exepath, cwd) == NULL) return -1;
char * str_pos = strrchr(cwd, '/');
if (str_pos == NULL) return -1;
diff --git a/src/main.c b/src/main.c
index 9e2a64e..51c22f5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -45,7 +45,7 @@ int shall_quit = 0;
unsigned int curmode = NORMAL_MODE;
int maxrow, maxcol;
char curfile[PATHLEN];
-char exepath[PATHLEN];
+char *exepath;
int changed;
int cellassign;
@@ -344,7 +344,7 @@ void read_argv(int argc, char ** argv) {
strcpy(curfile, argv[i]);
}
}
- strcpy(exepath, argv[0]);
+ exepath = argv[0];
}