forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit5c784d9
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 typename, which of course is wrong: after prepending '_' there is only room forNAMEDATALEN-2 bytes. Aside from being the wrong result, this case wouldlead to overrunning the statically allocated work buffer. This would be asecurity bug if the function were ever used outside bootstrap mode, but itisn't, at least not in any currently supported branches.Aside from fixing the off-by-one loop logic, this patch gets rid of thestatic work buffer by having MapArrayTypeName pstrdup its result; the solecaller was already doing that, so this just requires moving the pstrdupcall. 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 usingMapArrayTypeName with less-secure input. Pushing pstrdup into the functionshould not cause any serious problems for such hypothetical code; at worstthere might be a short term memory leak.Per Coverity scanning.1 parent926da21 commit5c784d9
File tree
3 files changed
+15
-20
lines changed- src
- backend/bootstrap
- include/bootstrap
3 files changed
+15
-20
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
104 | 104 |
| |
105 | 105 |
| |
106 | 106 |
| |
107 |
| - | |
| 107 | + | |
108 | 108 |
| |
109 | 109 |
| |
110 | 110 |
| |
|
Lines changed: 13 additions & 18 deletions
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 |
| |
|
Lines changed: 1 addition & 1 deletion
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
Comments
(0)