aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2020-04-29 17:10:08 +0200
committerAndreas Schneider <asn@cryptomilk.org>2020-05-05 14:23:06 +0200
commit3d0ecd37fe6b438a89ddc424fdd59a2689f96f2d (patch)
treeb545c230c04fa8b9b30faff65b13c0b7e4f130a7 /src
parent2e7ca3e8a6e1ae4dddd04d9d68197b2f8f87bf6d (diff)
downloadlibssh-3d0ecd37fe6b438a89ddc424fdd59a2689f96f2d.tar.gz
libssh-3d0ecd37fe6b438a89ddc424fdd59a2689f96f2d.tar.xz
libssh-3d0ecd37fe6b438a89ddc424fdd59a2689f96f2d.zip
options: Avoid memory leaks during modification of argv
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src')
-rw-r--r--src/options.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/src/options.c b/src/options.c
index f5c7bbb2..b2aeba89 100644
--- a/src/options.c
+++ b/src/options.c
@@ -1255,8 +1255,6 @@ int ssh_options_getopt(ssh_session session, int *argcptr, char **argv)
break;
default:
{
- char optv[3] = "- ";
- optv[1] = optopt;
tmp = realloc(save, (current + 1) * sizeof(char*));
if (tmp == NULL) {
SAFE_FREE(save);
@@ -1264,12 +1262,7 @@ int ssh_options_getopt(ssh_session session, int *argcptr, char **argv)
return -1;
}
save = tmp;
- save[current] = strdup(optv);
- if (save[current] == NULL) {
- SAFE_FREE(save);
- ssh_set_error_oom(session);
- return -1;
- }
+ save[current] = argv[optind-1];
current++;
/* We can not use optarg here as getopt does not set it for
* unknown options. We need to manually extract following