Draw: Fix possible segfault in textw (securize strcpy)

This commit is contained in:
Martin Duquesnoy 2010-03-28 16:09:00 +02:00
parent aa9609b5cf
commit 321669eb3a
2 changed files with 15 additions and 7 deletions

View File

@ -55,7 +55,7 @@ add_executable(wmfs ${wmfs_src})
set(VERSION "WMFS-201003")
# FLAGS
set(CFLAGS "-g -Wall -ansi")
set(CFLAGS "-Wall -ansi")
set(CMAKE_C_FLAGS ${CFLAGS})
# Linker FLAGS

View File

@ -57,10 +57,13 @@ draw_text(Drawable d, int x, int y, char* fg, int pad, char *str)
ostr = _strdup(str);
ni = parse_image_block(im, str);
if(strstr(str, "i["))
{
ni = parse_image_block(im, str);
for(i = 0; i < ni; ++i)
draw_image(d, im[i].x, im[i].y, im[i].w, im[i].h, im[i].name);
for(i = 0; i < ni; ++i)
draw_image(d, im[i].x, im[i].y, im[i].w, im[i].h, im[i].name);
}
#endif /* HAVE_IMLIB */
/* Transform X Drawable -> Xft Drawable */
@ -78,7 +81,9 @@ draw_text(Drawable d, int x, int y, char* fg, int pad, char *str)
XftDrawDestroy(xftd);
#ifdef HAVE_IMLIB
strcpy(str, ostr);
if(strstr(ostr, "i["))
strcpy(str, ostr);
IFREE(ostr);
#endif /* HAVE_IMLIB */
@ -165,13 +170,16 @@ textw(char *text)
ostr = _strdup(text);
parse_image_block(im, text);
if(strstr(text, "i["))
parse_image_block(im, text);
#endif /* HAVE_IMLIB */
XftTextExtentsUtf8(dpy, font, (FcChar8 *)text, strlen(text), &gl);
#ifdef HAVE_IMLIB
strcpy(text, ostr);
if(strstr(ostr, "i["))
strcpy(text, ostr);
IFREE(ostr);
#endif /* HAVE_IMLIB */