Re: [PATCH v3 2/3] git-core: Support retrieving passwords with GIT_ASKPASS

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

 



Frank Li schrieb:
> +	memset(&pass, 0, sizeof(pass));
> +	pass.argv = args;
> +	pass.out = -1;
> +	pass.use_shell = 1;

I thought that the conclusion was to follow how openssh treats
SSH_ASKPASS, and it *does not* treat it as a command with arguments. Do
not set use_shell.

> +	if (start_command(&pass)) {
> +		error("could not run %s\n", askpass);

As I said, this error message is redundant. No big deal, though.

> +		exit(1);
> +	}
> +
> +	strbuf_read(&buffer, pass.out, 20);
> +	close(pass.out);
> +	finish_command(&pass);

You must check for errors here as well. No error message is needed, either.

> +
> +	for (i = 0; i < buffer.len; i++)
> +		if (buffer.buf[i] == '\n' || buffer.buf[i] == '\r') {
> +			buffer.buf[i] = '\0';
> +			buffer.len = i;
> +		}

I think you can shorten this loop to

	strbuf_setlen(&buffer, strcspn(buffer.buf, "\r\n"));

-- Hannes

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