[gobject-introspection] scanner: Use PATH_MAX, not hardcoded 1024 for realpath()
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] scanner: Use PATH_MAX, not hardcoded 1024 for realpath()
- Date: Sat, 16 Nov 2013 16:00:10 +0000 (UTC)
commit ff2e8dd92d43e11705fcd2b493737bb58c4f2daa
Author: Colin Walters <walters verbum org>
Date: Sat Nov 16 10:55:15 2013 -0500
scanner: Use PATH_MAX, not hardcoded 1024 for realpath()
Otherwise we can overflow the stack on longer pathnames.
Tested-By: Mantas Mikulėnas <grawity gmail com>
giscanner/scannerlexer.l | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/giscanner/scannerlexer.l b/giscanner/scannerlexer.l
index f80a8d6..89a34b8 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]