summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojciech Nizinski <w.nizinski at grinn-global.com>2015-10-20 14:08:09 +0200
committerWaldemar Brodkorb <wbx@openadk.org>2015-12-17 20:35:20 +0100
commit5178df3e156a436c4888a1a95996aea55525e7b6 (patch)
tree91e85c6f73506dafa3c7a399ff9406e8a4c04b88
parent3aabb58d126445092dca953223c1730d975491dc (diff)
libc/stdlib: canonicalize_file_name() memory leak
Uclibc's canonicalize_file_name() is allocating temprary buffer of 4kB (PATH_MAX), and passing it to realpath() as second argument. Function is not checking if realpath() fails and memory is lost.
-rw-r--r--libc/stdlib/canonicalize.c21
1 files changed, 1 insertions, 20 deletions
diff --git a/libc/stdlib/canonicalize.c b/libc/stdlib/canonicalize.c
index 06e710ab7..da09d5841 100644
--- a/libc/stdlib/canonicalize.c
+++ b/libc/stdlib/canonicalize.c
@@ -9,30 +9,11 @@
*/
#include <stdlib.h>
-#include <limits.h>
#ifdef __USE_GNU
-#ifndef PATH_MAX
-# ifdef _POSIX_VERSION
-# define PATH_MAX _POSIX_PATH_MAX
-# else
-# ifdef MAXPATHLEN
-# define PATH_MAX MAXPATHLEN
-# else
-# define PATH_MAX 1024
-# endif
-# endif
-#endif
-
char * canonicalize_file_name (const char *name)
{
- char *buf = (char *) malloc(PATH_MAX);
-
- if(unlikely(buf == NULL))
- return NULL;
-
- *buf='\0';
- return realpath (name, buf);
+ return realpath (name, NULL);
}
#endif