Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP2:GA
perl.33799
perl-pack-overflow.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File perl-pack-overflow.diff of Package perl.33799
--- pp_pack.c.orig 2017-07-18 22:50:13.000000000 +0000 +++ pp_pack.c 2024-05-08 12:24:57.288682824 +0000 @@ -361,11 +361,28 @@ STMT_START { \ } \ } STMT_END +#define SAFE_UTF8_EXPAND(var) \ +STMT_START { \ + if ((var) > SSize_t_MAX / UTF8_EXPAND) \ + Perl_croak(aTHX_ "%s", "Out of memory during pack()"); \ + (var) = (var) * UTF8_EXPAND; \ +} STMT_END + +#define GROWING2(utf8, cat, start, cur, item_size, item_count) \ +STMT_START { \ + if (SSize_t_MAX / (item_size) < (item_count)) \ + Perl_croak(aTHX_ "%s", "Out of memory during pack()"); \ + GROWING((utf8), (cat), (start), (cur), (item_size) * (item_count)); \ +} STMT_END + #define GROWING(utf8, cat, start, cur, in_len) \ STMT_START { \ STRLEN glen = (in_len); \ - if (utf8) glen *= UTF8_EXPAND; \ - if ((cur) + glen >= (start) + SvLEN(cat)) { \ + STRLEN catcur = (STRLEN)((cur) - (start)); \ + if (utf8) SAFE_UTF8_EXPAND(glen); \ + if (SSize_t_MAX - glen < catcur) \ + Perl_croak(aTHX_ "%s", "Out of memory during pack()"); \ + if (catcur + glen >= SvLEN(cat)) { \ (start) = sv_exp_grow(cat, glen); \ (cur) = (start) + SvCUR(cat); \ } \ @@ -375,7 +392,7 @@ STMT_START { \ STMT_START { \ const STRLEN glen = (in_len); \ STRLEN gl = glen; \ - if (utf8) gl *= UTF8_EXPAND; \ + if (utf8) SAFE_UTF8_EXPAND(gl); \ if ((cur) + gl >= (start) + SvLEN(cat)) { \ *cur = '\0'; \ SvCUR_set((cat), (cur) - (start)); \ @@ -2135,7 +2152,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* sym if (props && !(props & PACK_SIZE_UNPREDICTABLE)) { /* We can process this letter. */ STRLEN size = props & PACK_SIZE_MASK; - GROWING(utf8, cat, start, cur, (STRLEN) len * size); + GROWING2(utf8, cat, start, cur, size, (STRLEN)len); } }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor