summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Torri <vincent dot torri at gmail dot com>2015-10-14 09:58:19 +0200
committerTom Hacohen <tom@stosb.com>2015-10-14 09:44:48 +0100
commit8854b9f72773f5b5a215d2e1477d064b647e34e9 (patch)
treebe8ab3770e2727550b36da688c0422f5f109266f
parentcfe181731502b7f22f6faa563566b7914c74cbf1 (diff)
Eina: fix eina_file_current_directory_get()
the length was not correctly computed and eina_file_path_sanitize() was was writing beyond the limit of the string @fix
-rw-r--r--src/lib/eina/eina_file_win32.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/lib/eina/eina_file_win32.c b/src/lib/eina/eina_file_win32.c
index 8139cad313..a1371d73f7 100644
--- a/src/lib/eina/eina_file_win32.c
+++ b/src/lib/eina/eina_file_win32.c
@@ -423,21 +423,19 @@ eina_file_path_relative(const char *path)
423Eina_Tmpstr * 423Eina_Tmpstr *
424eina_file_current_directory_get(const char *path, size_t len) 424eina_file_current_directory_get(const char *path, size_t len)
425{ 425{
426 char *cwd;
427 char *tmp; 426 char *tmp;
428 DWORD l; 427 DWORD l;
429 428
430 l = GetCurrentDirectory(0, NULL); 429 l = GetCurrentDirectory(0, NULL);
431 if (l <= 0) return NULL; 430 if (l == 0) return NULL;
432 431
433 cwd = alloca(sizeof(char) * (l + 1)); 432 tmp = alloca(sizeof (char) * (l + len + 2));
434 GetCurrentDirectory(l + 1, cwd); 433 l = GetCurrentDirectory(l + 1, tmp);
435 len += l + 2; 434 tmp[l] = '\\';
436 tmp = alloca(sizeof (char) * len); 435 memcpy(tmp + l + 1, path, len);
437 snprintf(tmp, len, "%s\\%s", cwd, path); 436 tmp[l + len + 1] = '\0';
438 tmp[len - 1] = '\0';
439 437
440 return eina_tmpstr_add_length(tmp, len); 438 return eina_tmpstr_add_length(tmp, l + len + 1);
441} 439}
442 440
443char * 441char *