fix potential bad memory access in change_filename_extension

This commit is contained in:
kreatordxx 2008-01-19 00:30:02 +00:00
parent 64f760e4f0
commit d77955652d
2 changed files with 4 additions and 1 deletions

View file

@ -5,6 +5,7 @@ D2X-Rebirth Changelog
main/network.c: fix typo causing compiler error on bigendian computers
2d/font.c: make sure a font header only takes up sizeof(grs_font) memory, not sizeof(grs_font) squared
arch/ogl/gr.c, arch/ogl/include/internal.h, arch/ogl/sdlgl.c, include/args.h, main/inferno.c, main/menu.c, main/newdemo.c, main/newmenu.c, misc/args.c: Removed SDL Gammaramp code (obsolete); Improvements on Demo code
misc/strutil.c: fix potential bad memory access in change_filename_extension
20080108
--------

View file

@ -142,11 +142,13 @@ void change_filename_extension( char *dest, char *src, char *ext )
p = strrchr(dest, '.');
if (!p) {
if (strlen(dest) > FILENAME_LEN - 5)
return; // a non-opened file is better than a bad memory access
p = dest + strlen(dest);
*p = '.';
}
Assert((p + strlen(ext)) - dest < FILENAME_LEN);
strcpy(p+1,ext);
}