mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2026-02-12 11:00:34 +01:00
dm_strword: fix invalid memory access
Calling this dm_strword with an emtpy 'str' can cause invalid memory
access. This commit checks for an empty string.
NOTE: This function is insecure and can cause segfaults
when 'str' is larger than 'source'
Signed-off-by: Daniel Danzberger <daniel@dd-wrt.com>
This commit is contained in:
parent
9ee0484353
commit
3b7fe9237b
1 changed files with 3 additions and 1 deletions
|
|
@ -1137,8 +1137,10 @@ static inline int isword_delim(char c)
|
|||
char *dm_strword(char *src, char *str)
|
||||
{
|
||||
char *ret = src;
|
||||
if (src[0] == '\0')
|
||||
|
||||
if (src[0] == 0 || str[0] == 0)
|
||||
return NULL;
|
||||
|
||||
int len = strlen(str);
|
||||
while ((ret = strstr(ret, str)) != NULL) {
|
||||
if ((ret == src && isword_delim(ret[len])) ||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue