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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to