git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Git Mailing List <git@vger.kernel.org>
Subject: [PATCH] rsh.c unterminated string
Date: Fri, 23 Sep 2005 16:30:50 -0700	[thread overview]
Message-ID: <4334902A.3010905@zytor.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 269 bytes --]

The change I made to rsh.c would leave the string unterminated under 
certain conditions, which unfortunately always applied!  This patch 
fixes this.  For some reason this never bit on i386 or ppc, but bit me 
on x86-64.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>

[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 1065 bytes --]

Fix situation where the buffer was not properly null-terminated.

---
commit 62f7819792e7152ae0dc241ed2f7e05e10c0d345
tree 865683d54a0c4d7604711d6b74233f79291eb8ac
parent acfadcfb48e34fdc441e9cffbb385fce9693b363
author Peter Anvin <hpa@tazenda.sc.orionmulti.com> Fri, 23 Sep 2005 16:22:33 -0700
committer Peter Anvin <hpa@tazenda.sc.orionmulti.com> Fri, 23 Sep 2005 16:22:33 -0700

 rsh.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/rsh.c b/rsh.c
--- a/rsh.c
+++ b/rsh.c
@@ -53,6 +53,7 @@ static int add_to_string(char **ptrp, in
 	char *p = *ptrp;
 	int size = *sizep;
 	int oc;
+	int err = 0;
 
 	if ( quote ) {
 		oc = shell_quote(p, size, str);
@@ -62,15 +63,14 @@ static int add_to_string(char **ptrp, in
 	}
 
 	if ( oc >= size ) {
-		p[size-1] = '\0';
-		*ptrp += size-1;
-		*sizep = 1;
-		return 1;	/* Overflow, string unusable */
+		err = 1;
+		oc = size-1;
 	}
 
 	*ptrp  += oc;
+	**ptrp  = '\0';
 	*sizep -= oc;
-	return 0;
+	return err;
 }
 
 int setup_connection(int *fd_in, int *fd_out, const char *remote_prog, 

                 reply	other threads:[~2005-09-23 23:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4334902A.3010905@zytor.com \
    --to=hpa@zytor.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).