[PATCH 1/3] ui-patch.c: Use log_tree_commit() to generate diffs

Lukas Fleischer cgit at cryptocrack.de
Thu Aug 15 20:52:24 CEST 2013


On Thu, Aug 15, 2013 at 12:37:03PM -0600, Jason A. Donenfeld wrote:
> On Thu, Aug 15, 2013 at 11:06 AM, Lukas Fleischer <cgit at cryptocrack.de> wrote:
> > +       char rev_range[2 * 20 + 2];>
> > +       sprintf(rev_range, "%s..%s", sha1_to_hex(old_sha1), sha1_to_hex(sha1));
> 
> If the strings coming out of sha1_to_hex were of length twenty, then
> rev_range would have to be of size 2*20+3, not +2, to account for the
> null terminator. But in fact sha1_to_hex produces length forty
> strings, so rev_range actually needs to be 2*40+3.

Ugh. I did this right in the original patch (well, at least the null
character) -- no idea why I messed it up here. I probably need more
coffee :)

Fixed it locally. Thanks! I will wait for further comments and resubmit
in a couple of hours.

> 
>         for (i = 0; i < 20; i++) {
>                 unsigned int val = *sha1++;
>                 *buf++ = hex[val >> 4];
>                 *buf++ = hex[val & 0xf];
>         }


More information about the CGit mailing list