Skip to content

Commit 957aefd

Browse files
author
Shishir Jaiswal
committed
Bug#23498283 - BUFFER OVERFLOW
DESCRIPTION =========== Buffer overflow is reported in Regex library. This can be triggered when the data corresponding to argv[1] is >= 512 bytes resutling in abnormal behaviour. ANALYSIS ======== Its a straight forward case of SEGFAULT where the target buffer is smaller than the source string to be copied. A simple pre-copy validation should do. FIX === A check is added before doing strcpy() to ensure that the target buffer is big enough to hold the to-be copied data. If the check fails, the program aborts.
1 parent df0d8ef commit 957aefd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

regex/split.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ char *argv[];
159159

160160
if (argc > 4)
161161
for (n = atoi(argv[3]); n > 0; n--) {
162+
if(sizeof(buf)-1 < strlen(argv[1]))
163+
{
164+
exit(EXIT_FAILURE);
165+
}
162166
(void) strcpy(buf, argv[1]);
163167
}
164168
else if (argc > 3)

0 commit comments

Comments
 (0)