Skip to content

Commit

Permalink
safestringlib: safeclib/strpbrk_s.c: check string boundaries
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Winkler <[email protected]>
  • Loading branch information
tomasbw committed Sep 13, 2023
1 parent b0cc18c commit 70580a3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions safeclib/strpbrk_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ strpbrk_s (char *dest, rsize_t dmax,
char *src, rsize_t slen, char **first)
{
char *ps;
rsize_t len;

if (first == NULL) {
invoke_safe_str_constraint_handler("strpbrk_s: count is null",
Expand Down Expand Up @@ -117,10 +116,9 @@ strpbrk_s (char *dest, rsize_t dmax,
*/
while (dmax && *dest) {

rsize_t len = slen;
ps = src;
len = slen;
while (*ps) {

while (*ps && len > 0) {
/* check for a match with the substring */
if (*dest == *ps) {
*first = dest;
Expand Down

0 comments on commit 70580a3

Please sign in to comment.