Put a simple sanity check in to prevent buffer overflows.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 29 May 2016 03:03:15 -0400
changeset 1176 1356c2c32ef6
parent 1175 9a010116e353
child 1177 ba7a3f39add4
Put a simple sanity check in to prevent buffer overflows.
mojoshader.c
--- a/mojoshader.c	Sun May 29 02:59:29 2016 -0400
+++ b/mojoshader.c	Sun May 29 03:03:15 2016 -0400
@@ -11169,8 +11169,13 @@
         return NULL;
     } // if
 
-    if (mainfn)
-        ctx->mainfn = StrDup(ctx, mainfn);
+    if (mainfn != NULL)
+    {
+        if (strlen(mainfn) > 55)  // !!! FIXME: just to keep things sane. Lots of hardcoded stack arrays...
+            failf(ctx, "Main function name '%s' is too big", mainfn);
+        else
+            ctx->mainfn = StrDup(ctx, mainfn);
+    } // if
 
     if (profile != NULL)
     {