Commit a2969bd
committed
Fix off-by-one loop count in MapArrayTypeName, and get rid of static array.
MapArrayTypeName would copy up to NAMEDATALEN-1 bytes of the base type
name, which of course is wrong: after prepending '_' there is only room for
NAMEDATALEN-2 bytes. Aside from being the wrong result, this case would
lead to overrunning the statically allocated work buffer. This would be a
security bug if the function were ever used outside bootstrap mode, but it
isn't, at least not in any currently supported branches.
Aside from fixing the off-by-one loop logic, this patch gets rid of the
static work buffer by having MapArrayTypeName pstrdup its result; the sole
caller was already doing that, so this just requires moving the pstrdup
call. This saves a few bytes but mainly it makes the API a lot cleaner.
Back-patch on the off chance that there is some third-party code using
MapArrayTypeName with less-secure input. Pushing pstrdup into the function
should not cause any serious problems for such hypothetical code; at worst
there might be a short term memory leak.
Per Coverity scanning.1 parent 961df18 commit a2969bd
File tree
3 files changed
+15
-20
lines changed- src
- backend/bootstrap
- include/bootstrap
3 files changed
+15
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1009 | 1009 | | |
1010 | 1010 | | |
1011 | 1011 | | |
1012 | | - | |
| 1012 | + | |
1013 | 1013 | | |
1014 | | - | |
1015 | | - | |
1016 | | - | |
1017 | | - | |
1018 | | - | |
1019 | 1014 | | |
1020 | | - | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
1021 | 1019 | | |
1022 | | - | |
1023 | | - | |
1024 | | - | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
1025 | 1023 | | |
1026 | 1024 | | |
1027 | | - | |
| 1025 | + | |
1028 | 1026 | | |
1029 | 1027 | | |
1030 | 1028 | | |
1031 | | - | |
| 1029 | + | |
1032 | 1030 | | |
1033 | | - | |
1034 | | - | |
1035 | | - | |
1036 | | - | |
1037 | 1031 | | |
1038 | | - | |
| 1032 | + | |
| 1033 | + | |
1039 | 1034 | | |
1040 | 1035 | | |
1041 | 1036 | | |
1042 | 1037 | | |
1043 | | - | |
| 1038 | + | |
1044 | 1039 | | |
1045 | 1040 | | |
1046 | 1041 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
0 commit comments