changeset 637:75807b0a3065

To prevent argument damage (like stripping curly braces) check if 'noglob' is set.
author Oleksandr Gavenko <gavenkoa@gmail.com>
date Mon, 31 Jul 2017 00:59:36 +0300
parents f15da8a6231a
children 4f6e9ce2af1a
files cygwin/cygrun/cygrun.c
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/cygwin/cygrun/cygrun.c	Mon Jul 31 00:45:01 2017 +0300
+++ b/cygwin/cygrun/cygrun.c	Mon Jul 31 00:59:36 2017 +0300
@@ -1,3 +1,4 @@
+#include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -21,6 +22,17 @@
         exit(1);
     }
 
+    /* To prevent argument damage (like stripping curly braces) check if 'noglob' is set. */
+    char *cygwin_env = getenv("CYGWIN");
+    if (cygwin_env == NULL) {
+        fprintf(stderr, "CYGWIN env var isn't set. We expect 'noglob' there.");
+        exit(EXIT_FAILURE);
+    }
+    if (strstr(cygwin_env, "noglob") == NULL) {
+        fprintf(stderr, "'noglob' is expected in CYGWIN env var.");
+        exit(EXIT_FAILURE);
+    }
+
     start = strrchr(*argv, '/');
     if (start)
         start++;