Fixed buffer overflow when p-res==targetlen in function getreqentry

This commit is contained in:
Adria Garriga 2014-08-07 02:11:46 +02:00 committed by FRIGN
parent e9408312e1
commit abec80e6ce

View file

@ -363,7 +363,7 @@ getreqentry(char *name, char *target, size_t targetlen, char *breakchars) {
for(p = res; *p && !strchr(breakchars, *p); ++p);
if(!*p)
return 1;
if((size_t)(p - res) > targetlen)
if((size_t)(p - res) >= targetlen)
return 1;
memcpy(target, res, p - res);
target[p - res] = 0;