Commit 6670913
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 de8e46f commit 6670913
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 | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1032 | 1032 | | |
1033 | 1033 | | |
1034 | 1034 | | |
1035 | | - | |
| 1035 | + | |
1036 | 1036 | | |
1037 | | - | |
1038 | | - | |
1039 | | - | |
1040 | | - | |
1041 | | - | |
1042 | 1037 | | |
1043 | | - | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
1044 | 1042 | | |
1045 | | - | |
1046 | | - | |
1047 | | - | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
1048 | 1046 | | |
1049 | 1047 | | |
1050 | | - | |
| 1048 | + | |
1051 | 1049 | | |
1052 | 1050 | | |
1053 | 1051 | | |
1054 | | - | |
| 1052 | + | |
1055 | 1053 | | |
1056 | | - | |
1057 | | - | |
1058 | | - | |
1059 | | - | |
1060 | 1054 | | |
1061 | | - | |
| 1055 | + | |
| 1056 | + | |
1062 | 1057 | | |
1063 | 1058 | | |
1064 | 1059 | | |
1065 | 1060 | | |
1066 | | - | |
| 1061 | + | |
1067 | 1062 | | |
1068 | 1063 | | |
1069 | 1064 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
0 commit comments