diff options
author | Colin Walters <walters@verbum.org> | 2013-11-16 10:55:15 -0500 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2013-11-16 10:58:45 -0500 |
commit | ff2e8dd92d43e11705fcd2b493737bb58c4f2daa (patch) | |
tree | 15ea96b87e0ea924bb6f21c9a7d3ac86ad80335f /giscanner/scannerlexer.l | |
parent | b45d3949422faeae297cfd4dd28a9a08df68f3b4 (diff) | |
download | gobject-introspection-ff2e8dd92d43e11705fcd2b493737bb58c4f2daa.tar.gz |
scanner: Use PATH_MAX, not hardcoded 1024 for realpath()1.39.0
Otherwise we can overflow the stack on longer pathnames.
Tested-By: Mantas Mikulėnas <grawity@gmail.com>
Diffstat (limited to 'giscanner/scannerlexer.l')
-rw-r--r-- | giscanner/scannerlexer.l | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/giscanner/scannerlexer.l b/giscanner/scannerlexer.l index f80a8d61..89a34b88 100644 --- a/giscanner/scannerlexer.l +++ b/giscanner/scannerlexer.l @@ -31,6 +31,9 @@ %{ #include <ctype.h> #include <stdio.h> +#ifndef _WIN32 +#include <limits.h> +#endif #include <glib.h> #include "sourcescanner.h" @@ -317,11 +320,22 @@ check_identifier (GISourceScanner *scanner, return IDENTIFIER; } +/* taken from glib/gfileutils.c */ +#if defined(MAXPATHLEN) +#define G_PATH_LENGTH MAXPATHLEN +#elif defined(PATH_MAX) +#define G_PATH_LENGTH PATH_MAX +#elif defined(_PC_PATH_MAX) +#define G_PATH_LENGTH sysconf(_PC_PATH_MAX) +#else +#define G_PATH_LENGTH 2048 +#endif + static inline char * _realpath (const char *path) { #ifndef _WIN32 - char buffer[1025]; + char buffer[G_PATH_LENGTH]; return realpath (path, buffer) ? g_strdup (buffer) : NULL; #else |