diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2013-03-05 22:24:15 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-03-05 12:27:32 -0800 |
commit | 30e10183caa3adaf088b9677b628c1d3512dfaf5 (patch) | |
tree | a1d52b7a96aff1438d9282218302b3bcfefdc4f6 /windows.c | |
parent | 07b2c204c9b0aa5d7a00ecba72241ea85d3339eb (diff) | |
download | subsurface-30e10183caa3adaf088b9677b628c1d3512dfaf5.tar.gz |
windows.c: Use a zeroed buffer when retrieving the module path
There is a small API note on GetModuleFileName(), which says:
"Windows XP: The string is truncated to nSize characters
and is not null-terminated."
Which means that on XP it will be only safe if we pass a zeroed
buffer to it, otherwise the next call to wcsrchr (which is
a strchr for wchar_t) may not find a relative terminating \0 in
the buffer, returning a wrong pointer and resulting in a corrupted
string.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'windows.c')
-rw-r--r-- | windows.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -243,7 +243,7 @@ extern int __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *); /* expand-convert the UTF-16 argument list to a list of UTF-8 strings */ void subsurface_command_line_init(gint *argc, gchar ***argv) { - wchar_t **wargv, **wenviron, *p, path[MAX_PATH]; + wchar_t **wargv, **wenviron, *p, path[MAX_PATH] = {0}; gchar **argv_new; gchar *s; /* for si we assume that a struct address will equal the address |