Skip to content

Commit 4ee034f

Browse files
author
Tomas Winkler
committed
safestringlib: safeclib/strpbrk_s.c: check string boundaries
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
1 parent b0cc18c commit 4ee034f

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

safeclib/strpbrk_s.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ strpbrk_s (char *dest, rsize_t dmax,
6767
char *src, rsize_t slen, char **first)
6868
{
6969
char *ps;
70-
rsize_t len;
7170

7271
if (first == NULL) {
7372
invoke_safe_str_constraint_handler("strpbrk_s: count is null",
@@ -117,10 +116,9 @@ strpbrk_s (char *dest, rsize_t dmax,
117116
*/
118117
while (dmax && *dest) {
119118

119+
rsize_t len = slen;
120120
ps = src;
121-
len = slen;
122-
while (*ps) {
123-
121+
while (*ps && len > 0) {
124122
/* check for a match with the substring */
125123
if (*dest == *ps) {
126124
*first = dest;

0 commit comments

Comments
 (0)