Re: [PATCH] http-push: trim trailing newline from remote symref

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 12, 2015 at 09:28:58PM -0500, Jeff King wrote:

> When we fetch a symbolic ref file from the remote, we get
> the whole string "ref: refs/heads/master\n", recognize it by
> skipping past the "ref: ", and store the rest. We should
> chomp the trailing newline.
> 
> This bug was introduced in ae021d8 (use skip_prefix to avoid
> magic numbers, 2014-06-18), which did not notice that the
> length computation fed to xmemdupz was quietly tweaked by 1
> to account for this.
> 
> We can solve it by explicitly trimming the newline, which is
> more obvious. Note that we use strbuf_rtrim here, which will
> actually cut off any trailing whitespace, not just a single
> newline. This is a good thing, though, as it makes our
> parsing more liberal (and spaces are not valid in refnames
> anyway).

While looking into Kyle's earlier response, I found that there is a
semi-duplicate of this function for the http-walker side:
http_fetch_ref. It already uses strbuf_rtrim, so I feel doubly good
about moving to its use here.

Almost certainly this duplicated functionality could be factored out. I
have very little interest in spending time cleaning up the http-push
code, though.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]