From: havoc Date: Thu, 2 Jun 2005 09:51:34 +0000 (+0000) Subject: fix a stack smash possibility in loadimagepixels X-Git-Tag: xonotic-v0.1.0preview~4806 X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=b84eea71053e3d3845903c557e251bd3f81f57ef fix a stack smash possibility in loadimagepixels git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5376 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/image.c b/image.c index 077baa7f..ebed4743 100644 --- a/image.c +++ b/image.c @@ -692,7 +692,8 @@ qbyte *loadimagepixels (const char *filename, qboolean complain, int matchwidth, Mem_CheckSentinelsGlobal(); if (developer_texturelogging.integer) Log_Printf("textures.log", "%s\n", filename); - Image_StripImageExtension(filename, basename); // strip filename extensions to allow replacement by other types + strlcpy(basename, filename, sizeof(basename)); + Image_StripImageExtension(basename, basename); // strip filename extensions to allow replacement by other types // replace *'s with #, so commandline utils don't get confused when dealing with the external files for (c = basename;*c;c++) if (*c == '*') @@ -1521,7 +1522,8 @@ int image_loadskin(imageskin_t *s, char *shadername) qbyte *bumppixels; int bumppixels_width, bumppixels_height; char name[MAX_QPATH]; - Image_StripImageExtension(shadername, name); + strlcpy(name, shadername, sizeof(name)); + Image_StripImageExtension(name, name); memset(s, 0, sizeof(*s)); s->basepixels = loadimagepixels(name, false, 0, 0); if (s->basepixels == NULL)