Commit d9e557a
show-branch: store resolved head in heap buffer
We resolve HEAD and copy the result to a fixed-size buffer
with memcpy, never checking that it actually fits. This bug
dates back to 8098a17 (Add git-symbolic-ref, 2005-09-30).
Before that we used readlink(), which took a maximum buffer
size.
We can fix this by using resolve_refdup(), which duplicates
the buffer on the heap. That also lets us just check
for a NULL pointer to see if we have resolved HEAD, and
drop the extra head_p variable.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent e6a7c75 commit d9e557a
1 file changed
Lines changed: 5 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
473 | 473 | | |
474 | 474 | | |
475 | 475 | | |
476 | | - | |
477 | | - | |
| 476 | + | |
478 | 477 | | |
479 | 478 | | |
480 | 479 | | |
| |||
621 | 620 | | |
622 | 621 | | |
623 | 622 | | |
624 | | - | |
625 | | - | |
| 623 | + | |
626 | 624 | | |
627 | 625 | | |
628 | 626 | | |
| |||
786 | 784 | | |
787 | 785 | | |
788 | 786 | | |
789 | | - | |
790 | | - | |
791 | | - | |
792 | | - | |
793 | | - | |
794 | | - | |
795 | | - | |
796 | | - | |
797 | | - | |
| 787 | + | |
| 788 | + | |
798 | 789 | | |
799 | | - | |
| 790 | + | |
800 | 791 | | |
801 | 792 | | |
802 | 793 | | |
| |||
0 commit comments