Commit b2f69fa
cat-file: validate remote atoms with an allow-list
strstr() is not enough to validate the format placeholders in
remote-object-info causing two errors:
1. Atoms recognized by expand_atom() but the remote doesn't returns 1,
but data->type contains garbage causing segfault.
2. expand_atom() returns 0 for unknown atoms, calling
strbuf_expand_bad_format() which ends up dying, blocking local
queries if the same format is shared.
Add an allow-list with the supported atoms at the top of expand_atom().
In remote mode, unsupported atoms return 1 leaving the buffer empty,
honoring how for-each-ref handles known but inapplicable atoms.
As extra safety, initialize data->type to OBJ_BAD and add a NULL check
for type_name() so uninitialized data doesn't cause segfault.
Update tests that expect previous die() behavior to expect an empty
string and add an explicit test for empty string return on unknown
placeholder.
Update cat-file command documentation regarding remote-object-info.
Mentored-by: Karthik Nayak <karthik.188@gmail.com>
Mentored-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent 1efc301 commit b2f69fa
3 files changed
Lines changed: 57 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
451 | 451 | | |
452 | 452 | | |
453 | 453 | | |
454 | | - | |
| 454 | + | |
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
339 | 350 | | |
340 | | - | |
341 | 351 | | |
342 | 352 | | |
343 | 353 | | |
| |||
348 | 358 | | |
349 | 359 | | |
350 | 360 | | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
351 | 376 | | |
352 | 377 | | |
353 | 378 | | |
354 | 379 | | |
355 | | - | |
| 380 | + | |
356 | 381 | | |
357 | | - | |
358 | | - | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
359 | 386 | | |
360 | 387 | | |
361 | 388 | | |
| |||
711 | 738 | | |
712 | 739 | | |
713 | 740 | | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | 741 | | |
719 | 742 | | |
720 | 743 | | |
| |||
844 | 867 | | |
845 | 868 | | |
846 | 869 | | |
| 870 | + | |
847 | 871 | | |
| 872 | + | |
848 | 873 | | |
849 | 874 | | |
850 | 875 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
239 | 254 | | |
240 | 255 | | |
241 | 256 | | |
| |||
575 | 590 | | |
576 | 591 | | |
577 | 592 | | |
578 | | - | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
579 | 596 | | |
580 | 597 | | |
581 | | - | |
| 598 | + | |
582 | 599 | | |
583 | 600 | | |
584 | 601 | | |
| |||
587 | 604 | | |
588 | 605 | | |
589 | 606 | | |
590 | | - | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
591 | 610 | | |
592 | 611 | | |
593 | | - | |
| 612 | + | |
594 | 613 | | |
595 | 614 | | |
596 | 615 | | |
| |||
0 commit comments