- Notifications
You must be signed in to change notification settings - Fork587
Commit7047915
Fix read/write past buffer end: perl-security#140
A package name may be specified in a \p{...} regular expressionconstruct. If unspecified, "utf8::" is assumed, which is the packageall official Unicode properties are in. By specifying a differentpackage, one can create a user-defined property with the sameunqualified name as a Unicode one. Such a property is defined by a subwhose name begins with "Is" or "In", and if the sub wishes to refer toan official Unicode property, it must explicitly specify the "utf8::".S_parse_uniprop_string() is used to parse the interior of both \p{} andthe user-defined sub lines.In S_parse_uniprop_string(), it parses the input "name" parameter,creating a modified copy, "lookup_name", malloc'ed with the same size as"name". The modifications are essentially to create a canonicalizedversion of the input, with such things as extraneous white-spacestripped off. I found it convenient to strip off the package specifier"utf8::". To to so, the code simply pretends "lookup_name" begins justafter the "utf8::", and adjusts various other values to compensate.However, it missed the adjustment of one required one.This is only a problem when the property name begins with "perl" andisn't "perlspace" nor "perlword". All such ones are undocumentedinternal properties.What happens in this case is that the input is reparsed with slightlydifferent rules in effect as to what is legal versus illegal. Theproblem is that "lookup_name" no longer is pointing to its initialvalue, but "name" is. Thus the space allocated for filling "lookup_name"is now shorter than "name", and as this shortened "lookup_name" isfilled by copying suitable portions of "name", the write can be tounallocated space.The solution is to skip the "utf8::" when reparsing "name". Then both"lookup_name" and "name" are effectively shortened by the same amount,and there is no going off the end.This commit also does white-space adjustment so that things alignvertically for readability.This can be easily backported to earlier Perl releases.1 parentbf7e5c2 commit7047915
2 files changed
+19
-6
lines changedLines changed: 11 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
24178 | 24178 |
| |
24179 | 24179 |
| |
24180 | 24180 |
| |
24181 |
| - | |
| 24181 | + | |
24182 | 24182 |
| |
24183 | 24183 |
| |
24184 | 24184 |
| |
| |||
24312 | 24312 |
| |
24313 | 24313 |
| |
24314 | 24314 |
| |
24315 |
| - | |
24316 |
| - | |
24317 |
| - | |
| 24315 | + | |
| 24316 | + | |
| 24317 | + | |
| 24318 | + | |
| 24319 | + | |
| 24320 | + | |
| 24321 | + | |
24318 | 24322 |
| |
24319 | 24323 |
| |
24320 | 24324 |
| |
| |||
24728 | 24732 |
| |
24729 | 24733 |
| |
24730 | 24734 |
| |
24731 |
| - | |
| 24735 | + | |
| 24736 | + | |
24732 | 24737 |
| |
24733 | 24738 |
| |
24734 | 24739 |
| |
| |||
24749 | 24754 |
| |
24750 | 24755 |
| |
24751 | 24756 |
| |
24752 |
| - | |
| 24757 | + | |
24753 | 24758 |
| |
24754 | 24759 |
| |
24755 | 24760 |
| |
|
Lines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2688 | 2688 |
| |
2689 | 2689 |
| |
2690 | 2690 |
| |
| 2691 | + | |
| 2692 | + | |
| 2693 | + | |
| 2694 | + | |
| 2695 | + | |
| 2696 | + | |
| 2697 | + | |
| 2698 | + | |
2691 | 2699 |
| |
2692 | 2700 |
| |
2693 | 2701 |
| |
|
0 commit comments
Comments
(0)