Commit af4d2e8
src: fix freeing unintialized pointer bug in ParseSoaReply
ares_expand_name doesn't guarantee that pointer variable is initialized
if return code is ARES_EBADNAME or ARES_ENOMEM. But current usage of the
function in the codebase thinks otherwise.
There seems to be an assumption that pointer is always initialized even
though it is a local variable and we create a unique pointer soon after
calling ares_expand_name. This could potentially crash the program with
an invalid free pointer.
I was able to crash it by poisoning the memory and some manual hooks.
By moving the unique_ptr after checking the return code we can fix the
problem. As the underlying function guarantees that pointer is
initialized when the status is ARES_SUCCESS.
PR-URL: nodejs#35502
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>1 parent ac7ba18 commit af4d2e8
1 file changed
+10
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1060 | 1060 | | |
1061 | 1061 | | |
1062 | 1062 | | |
1063 | | - | |
| 1063 | + | |
1064 | 1064 | | |
1065 | 1065 | | |
1066 | | - | |
1067 | 1066 | | |
1068 | 1067 | | |
1069 | 1068 | | |
1070 | 1069 | | |
1071 | 1070 | | |
| 1071 | + | |
| 1072 | + | |
1072 | 1073 | | |
1073 | 1074 | | |
1074 | 1075 | | |
1075 | 1076 | | |
1076 | 1077 | | |
1077 | 1078 | | |
1078 | | - | |
| 1079 | + | |
1079 | 1080 | | |
1080 | 1081 | | |
1081 | | - | |
1082 | 1082 | | |
1083 | 1083 | | |
1084 | 1084 | | |
1085 | 1085 | | |
| 1086 | + | |
| 1087 | + | |
1086 | 1088 | | |
1087 | 1089 | | |
1088 | 1090 | | |
| |||
1094 | 1096 | | |
1095 | 1097 | | |
1096 | 1098 | | |
1097 | | - | |
| 1099 | + | |
1098 | 1100 | | |
1099 | 1101 | | |
1100 | 1102 | | |
1101 | 1103 | | |
1102 | 1104 | | |
1103 | | - | |
1104 | 1105 | | |
1105 | 1106 | | |
1106 | 1107 | | |
| 1108 | + | |
1107 | 1109 | | |
1108 | 1110 | | |
1109 | | - | |
| 1111 | + | |
1110 | 1112 | | |
1111 | 1113 | | |
1112 | 1114 | | |
1113 | 1115 | | |
1114 | | - | |
1115 | 1116 | | |
1116 | 1117 | | |
1117 | 1118 | | |
| 1119 | + | |
1118 | 1120 | | |
1119 | 1121 | | |
1120 | 1122 | | |
| |||
0 commit comments