Commit 6648c1d
authored
fix(arrow/cdata, arrow/flight): fix handling of colons in values and fix potential panics (#761)
### fix(arrow/cdata): importSchema: handle colons in values
Use strings.Cut, both as an optimization, and to prevent values
containing
a colon (e.g. "tsu:+01:00") from being mis-interpreted. This patch also
removes some intermediate variables, and redundant handling of
"defaulttz",
which assigned an empty string if the value was empty.
### fix(arrow/cdata): importSchema: fix potential panic and optimize
Rewrite the code with strings.Cut and strings.SplitSeq to reduce
allocations, and to fix a potential panic.
Before this patch, the code would panic if a colon was missing;
CGO_ENABLED=1 go test -v -tags test -run TestUnionSchemaErrors
./arrow/cdata/
--- FAIL: TestUnionSchemaErrors (0.00s)
--- FAIL: TestUnionSchemaErrors/+us (0.00s)
panic: runtime error: index out of range [1] with length 1 [recovered,
repanicked]
goroutine 9 [running]:
testing.tRunner.func1.2({0x7fc7c0, 0x4000026ab0})
/usr/local/go/src/testing/testing.go:1872 +0x190
testing.tRunner.func1()
/usr/local/go/src/testing/testing.go:1875 +0x31c
panic({0x7fc7c0?, 0x4000026ab0?})
/usr/local/go/src/runtime/panic.go:783 +0x120
github.com/apache/arrow-go/v18/arrow/cdata.importSchema(0x40001c36d0)
/foo/arrow/cdata/cdata.go:306 +0x1520
github.com/apache/arrow-go/v18/arrow/cdata.ImportCArrowField(...)
/foo/arrow/cdata/interface.go:43
github.com/apache/arrow-go/v18/arrow/cdata.TestUnionSchemaErrors.func1(0x40000e0a80)
/foo/arrow/cdata/cdata_test.go:188 +0xb0
testing.tRunner(0x40000e0a80, 0x400020c060)
/usr/local/go/src/testing/testing.go:1934 +0xc8
created by testing.(*T).Run in goroutine 8
/usr/local/go/src/testing/testing.go:1997 +0x364
FAIL github.com/apache/arrow-go/v18/arrow/cdata 0.007s
FAIL
With this patch applied, the code handles the invalid value gracefully;
CGO_ENABLED=1 go test -v -tags test -run TestUnionSchemaErrors
./arrow/cdata/
=== RUN TestUnionSchemaErrors
=== RUN TestUnionSchemaErrors/+us
=== RUN TestUnionSchemaErrors/+ud
--- PASS: TestUnionSchemaErrors (0.00s)
--- PASS: TestUnionSchemaErrors/+us (0.00s)
--- PASS: TestUnionSchemaErrors/+ud (0.00s)
PASS
ok github.com/apache/arrow-go/v18/arrow/cdata 0.003s
### fix(arrow/flight): avoid panic on malformed authorization header
Rewrite the code with strings.Cut for readability and ensue missing
credentials
in Basic/Bearer authorization headers return Unauthenticated instead of
panicking.
Before this patch, the code could panic;
go test -run TestBasicAuthMissingCredential ./arrow/flight/
panic: runtime error: index out of range [1] with length 1
goroutine 7 [running]:
github.com/apache/arrow-go/v18/arrow/flight_test.TestBasicAuthMissingCredential.CreateServerBasicAuthMiddleware.createServerBearerTokenStreamInterceptor.func3({0x8d8240,
0x40002134a0}, {0xa73e68, 0x40000e2000}, 0x40000100c0, 0x96b628)
/foo/arrow/flight/server_auth.go:188 +0x49c
....
With this patch applied, the code handles the invalid header gracefully;
go test -run TestBasicAuthMissingCredential ./arrow/flight/
ok github.com/apache/arrow-go/v18/arrow/flight 0.010s
### Rationale for this change
### What changes are included in this PR?
### Are these changes tested?
### Are there any user-facing changes?
---------
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>1 parent 2e44b72 commit 6648c1d
4 files changed
Lines changed: 92 additions & 39 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
205 | | - | |
206 | | - | |
207 | | - | |
| 205 | + | |
208 | 206 | | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
| 207 | + | |
214 | 208 | | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
| 209 | + | |
220 | 210 | | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
| 211 | + | |
226 | 212 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
| 213 | + | |
232 | 214 | | |
233 | | - | |
| 215 | + | |
234 | 216 | | |
235 | 217 | | |
236 | 218 | | |
237 | 219 | | |
238 | 220 | | |
239 | | - | |
| 221 | + | |
240 | 222 | | |
241 | 223 | | |
242 | 224 | | |
| |||
317 | 299 | | |
318 | 300 | | |
319 | 301 | | |
320 | | - | |
321 | | - | |
322 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
323 | 308 | | |
324 | 309 | | |
325 | 310 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
177 | 195 | | |
178 | 196 | | |
179 | 197 | | |
| |||
195 | 213 | | |
196 | 214 | | |
197 | 215 | | |
| 216 | + | |
| 217 | + | |
198 | 218 | | |
199 | 219 | | |
200 | 220 | | |
| 221 | + | |
201 | 222 | | |
202 | 223 | | |
203 | 224 | | |
| |||
207 | 228 | | |
208 | 229 | | |
209 | 230 | | |
210 | | - | |
| 231 | + | |
211 | 232 | | |
212 | 233 | | |
213 | 234 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
| 173 | + | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
| 176 | + | |
177 | 177 | | |
178 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
179 | 181 | | |
180 | 182 | | |
181 | 183 | | |
182 | | - | |
| 184 | + | |
183 | 185 | | |
184 | 186 | | |
185 | 187 | | |
186 | 188 | | |
187 | | - | |
188 | | - | |
| 189 | + | |
| 190 | + | |
189 | 191 | | |
190 | | - | |
| 192 | + | |
191 | 193 | | |
192 | 194 | | |
193 | 195 | | |
| |||
199 | 201 | | |
200 | 202 | | |
201 | 203 | | |
202 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
203 | 207 | | |
204 | 208 | | |
205 | 209 | | |
206 | 210 | | |
207 | 211 | | |
208 | | - | |
209 | | - | |
| 212 | + | |
| 213 | + | |
210 | 214 | | |
211 | 215 | | |
212 | 216 | | |
| |||
0 commit comments