Commit 5c784d9
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 926da21 commit 5c784d9
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 | |
|---|---|---|---|
| |||
1016 | 1016 | | |
1017 | 1017 | | |
1018 | 1018 | | |
1019 | | - | |
| 1019 | + | |
1020 | 1020 | | |
1021 | | - | |
1022 | | - | |
1023 | | - | |
1024 | | - | |
1025 | | - | |
1026 | 1021 | | |
1027 | | - | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
1028 | 1026 | | |
1029 | | - | |
1030 | | - | |
1031 | | - | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
1032 | 1030 | | |
1033 | 1031 | | |
1034 | | - | |
| 1032 | + | |
1035 | 1033 | | |
1036 | 1034 | | |
1037 | 1035 | | |
1038 | | - | |
| 1036 | + | |
1039 | 1037 | | |
1040 | | - | |
1041 | | - | |
1042 | | - | |
1043 | | - | |
1044 | 1038 | | |
1045 | | - | |
| 1039 | + | |
| 1040 | + | |
1046 | 1041 | | |
1047 | 1042 | | |
1048 | 1043 | | |
1049 | 1044 | | |
1050 | | - | |
| 1045 | + | |
1051 | 1046 | | |
1052 | 1047 | | |
1053 | 1048 | | |
| |||
| 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