Re: [PATCH v4 4/9] index-helper: new daemon for caching index and related stuff

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

 



On Sun, 2015-11-01 at 14:42 +0100, Nguyễn Thái Ngọc Duy wrote:
> +	memcpy(new_mmap, istate->mmap, istate->mmap_size - 20);
> +
> +	/*
> +	 * The trailing hash must be written last after everything is
> +	 * written. It's the indication that the shared memory is now
> +	 * ready.
> +	 */
> +	hashcpy((unsigned char *)new_mmap + istate->mmap_size - 20, is->sha1);
> +}

You need a memory barrier here.  Otherwise, compilers may reorder these
statements.

> +#define SHM_PATH_LEN 72		/* we don't create very long paths.. */
> +
> +ssize_t git_shm_map(int oflag, int perm, ssize_t length, void **mmap,
> +		    int prot, int flags, const char *fmt, ...)
> +{
> +	va_list ap;
> +	char path[SHM_PATH_LEN];
> +	int fd;
> +
> +	path[0] = '/';
> +	va_start(ap, fmt);
> +	vsprintf(path + 1, fmt, ap);
> +	va_end(ap);

This would be safer with vsnprintf.


--
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]