Skip to content

Commit

Permalink
Fix mbtowc_test:mbtowc.
Browse files Browse the repository at this point in the history
  • Loading branch information
trasz committed Jul 23, 2018
1 parent 9b71798 commit 92bb865
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/libc/locale/gb18030.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,19 @@ _GB18030_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s,
pwc = NULL;
}

ncopy = MIN(MIN(n, MB_CUR_MAX), sizeof(gs->bytes) - gs->count);
/*
* CHERI CHANGES START
* {
* "updated": 20180723,
* "target_type": "lib",
* "changes": [
* "buffer_overrun"
* ],
* "change_comment": "fixes mbtowc_test:mbtowc"
* }
* CHERI CHANGES END
*/
ncopy = MIN(MIN(MIN(n, MB_CUR_MAX), sizeof(gs->bytes) - gs->count), strlen(s));
memcpy(gs->bytes + gs->count, s, ncopy);
ocount = gs->count;
gs->count += ncopy;
Expand Down

0 comments on commit 92bb865

Please sign in to comment.