Commit 126a29c
PrivHelper: fix two [de]serialization bugs
Summary:
# This diff
Fixes some [de]serialization logic in the PrivHelper. The two bugs were:
1) We were previously [de]serializing some values as uint32_t instead of int32_t
2) We were returning an uint64_t when deserializing a uint32_t. This caused us to potentially "narrow"/truncate values when assigning the result to a variable that's smaller than uint64_t.
I have convinced myself that this should be safe, since:
1) For problem #1, we don't use signed values anywhere, so the change from uint32_t to int32_t should be no-op. Additionally, all the values we use are sufficiently small such that uint32_t -> int32_t shouldn't cause overflow.
2) For problem #2, the deserialized values should always be <= MAX_UINT32 because we only accept uint32_t values when serializing. In addition, no users of the function currently expect a uint64_t to be returned (they all accidentally truncate the value). Therefore, the change to the type should be no-op.
Reviewed By: genevievehelsel
Differential Revision: D77240439
fbshipit-source-id: 90a4c49a1bde8428e4a4c50c5665c4889743eeaa1 parent 3225468 commit 126a29c
1 file changed
+13
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
136 | 144 | | |
137 | 145 | | |
138 | 146 | | |
| |||
168 | 176 | | |
169 | 177 | | |
170 | 178 | | |
171 | | - | |
| 179 | + | |
172 | 180 | | |
173 | | - | |
| 181 | + | |
174 | 182 | | |
175 | 183 | | |
176 | 184 | | |
| |||
186 | 194 | | |
187 | 195 | | |
188 | 196 | | |
189 | | - | |
| 197 | + | |
190 | 198 | | |
191 | | - | |
| 199 | + | |
192 | 200 | | |
193 | 201 | | |
194 | 202 | | |
| |||
0 commit comments