Re: [PATCH 1/1] clone: replace relative paths in the alternates

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

 



Hui Wang <jason77.wang@xxxxxxxxx> writes:

> +	mapsz = xsize_t(st.st_size);
> +	map = xmmap(NULL, mapsz, PROT_READ, MAP_PRIVATE, fd, 0);
> +	close(fd);
> +
> +	tmpbuf = mapsz > 4096 ? xmalloc(mapsz * 2) : xmalloc(mapsz + 4096);

Where do these magic numbers come from, and what guarantee do we have that
these magic numbers give safe upper bound for pathnames that are expanded
to be absolute?

Wouldn't it be a lot cleaner and much less error prone if you open the
original, read from it with strbuf_readline(), convert the path using
strbuf manipulation functions and write the resulting line out to the
lockfile you obtained to update it, line by line?
--
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]