From fd60b5ea108b35aa0b35e8632a7516badd9ca377 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 29 May 2016 03:03:15 -0400 Subject: [PATCH] Put a simple sanity check in to prevent buffer overflows. --- mojoshader.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mojoshader.c b/mojoshader.c index 8498d601..d9dbe454 100644 --- a/mojoshader.c +++ b/mojoshader.c @@ -11169,8 +11169,13 @@ static Context *build_context(const char *profile, 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) {