X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=rsh.c;h=1fef6da513b8157331b1a71c1d4c8df4c438498e;hb=25785195eebcd700e854e1bcc89f8d5e711523e2;hp=1c636861ddec037854240d6d3f5fa517d605bc2f;hpb=0de68d28d34f915951324b9f387e6e67172e9951;p=git.git diff --git a/rsh.c b/rsh.c index 1c636861..1fef6da5 100644 --- a/rsh.c +++ b/rsh.c @@ -53,6 +53,7 @@ static int add_to_string(char **ptrp, int *sizep, const char *str, int quote) 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, int *sizep, const char *str, int quote) } 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, @@ -104,7 +104,7 @@ int setup_connection(int *fd_in, int *fd_out, const char *remote_prog, if (!path) { return error("Bad URL: %s", url); } - /* $GIT_RSH "env GIR_DIR= " */ + /* $GIT_RSH "env GIT_DIR= " */ sizen = COMMAND_SIZE; posn = command; of = 0;