Re: [PATCH 2/4] receive-pack: implement advertising and receiving push options

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

 



Stefan Beller <sbeller@xxxxxxxxxx> writes:

> +static const char *stream_push_options_to_file()
> +{
> +	static const char *fname = "push-options-XXXXXX";
> +	char *ret = xmallocz(strlen(fname));
> +	int fd;
> +	memcpy(ret, fname, strlen(fname));
> +	fd = mkstemp(ret);

Probably

	char *ret;
	int fd;

	ret = xstrdup("push-options-XXXXXX");
	fd = xmkstemp(ret);

or use mkstemp but check the return value and "goto fail".

> +	for (;;) {
> +		char *line;
> +		int len;
> +
> +		line = packet_read_line(0, &len);
> +
> +		if (!line)
> +			break;
> +
> +		if (write_in_full(fd, line, len) < 0 ||
> +		    write_in_full(fd, "\n", 1) < 0)
> +			goto fail;
> +	}
> +
> +	return ret;
> +fail:
> +	close(fd);
> +	free(ret);
> +	return NULL;
> +}
> +
>  static const char *parse_pack_header(struct pack_header *hdr)
>  {
>  	switch (read_pack_header(0, hdr)) {
> @@ -1767,6 +1808,9 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
>  		const char *unpack_status = NULL;
>  		const char *push_options_file = NULL;
>  
> +		if (use_push_options)
> +			push_options_file = stream_push_options_to_file();
> +
>  		prepare_shallow_info(&si, &shallow);
>  		if (!si.nr_ours && !si.nr_theirs)
>  			shallow_update = 0;
--
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]