diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-04-01 08:30:12 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-04-01 08:31:43 +0200 |
commit | dd242e1ab71cb1b63b9cf9d56d93b5a6839b8777 (patch) | |
tree | d01c80bcf971395828af45e94a2d70a91b2a97df | |
parent | 65a61050376390c2bd702b22e8e12c934db9664c (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.c | 2 | ||||
-rw-r--r-- | src/main.c | 4 |
2 files changed, 3 insertions, 3 deletions
@@ -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; @@ -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]; } |