From: Johannes Sixt Date: Tue, 02 Mar 2010 12:17:22 GMT Subject: Re: [PATCH v3 2/3] git-core: Support retrieving passwords with GIT_ASKPASS Message-ID: <4B8D01D2.9060406@viscovery.net> In-Reply-To: <1267530657-4848-1-git-send-email-lznuaa@gmail.com> 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