summaryrefslogtreecommitdiffstats
path: root/qacp.c
diff options
context:
space:
mode:
authorNathan Straz <nstraz@redhat.com>2009-02-05 17:32:02 -0500
committerNathan Straz <nstraz@redhat.com>2009-02-05 17:32:02 -0500
commit1b52e677a1368f68e6c450a61235461c64f7e7bf (patch)
treebba426f84e46b8ce0607a6af58f800cfe851ea33 /qacp.c
parented36373d0d92306cd89085be00637c1c3624edff (diff)
downloadqarsh-1b52e677a1368f68e6c450a61235461c64f7e7bf.tar.gz
qarsh-1b52e677a1368f68e6c450a61235461c64f7e7bf.tar.xz
qarsh-1b52e677a1368f68e6c450a61235461c64f7e7bf.zip
[qacp] Fix improper free when connect fails
Freeing from the middle of an allocated string is not right. Keep a pointer to the strdup so we can free it correctly.
Diffstat (limited to 'qacp.c')
-rw-r--r--qacp.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/qacp.c b/qacp.c
index 2c39c96..6ddf414 100644
--- a/qacp.c
+++ b/qacp.c
@@ -479,7 +479,7 @@ recvfiles(char **argv, int argc, int fileidx, short recursive)
int
sendfiles(char **argv, int argc, int fileidx, short recursive)
{
- char *cp, *cp2;
+ char *cp, *cp2, *freeme;
char *rhost = NULL;
char *ruser = NULL;
char *rgrp = NULL;
@@ -500,7 +500,7 @@ sendfiles(char **argv, int argc, int fileidx, short recursive)
return -1;
}
- rhost = strdup(argv[argc-1]);
+ freeme = rhost = strdup(argv[argc-1]);
cp = strchr(rhost, ':');
*cp = '\0';
@@ -518,7 +518,7 @@ sendfiles(char **argv, int argc, int fileidx, short recursive)
if (!(pw = getpwuid(getuid()))) {
fprintf(stderr, "qacp: unknown user id.\n");
- free(rhost);
+ free(freeme);
return -1;
}
@@ -536,7 +536,7 @@ sendfiles(char **argv, int argc, int fileidx, short recursive)
rhost, QARSHD_CONTROL_PORT, errno, strerror(errno));
}
- free(rhost);
+ free(freeme);
return -1;
}
@@ -593,7 +593,7 @@ sendfiles(char **argv, int argc, int fileidx, short recursive)
} else {
fprintf(stderr, "%s:%s - %s\n", rhost, rmtpath,
strerror(rstaterrno));
- free(rhost);
+ free(freeme);
return -1;
}
}