diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2021-05-17 12:02:59 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2021-05-17 12:02:59 +0000 |
commit | 1fb6e9aee541f18f48c218681d65a9d560faf006 (patch) | |
tree | 770f906998b45e78c2b50a265fbd85962e8dda3f /usr.bin/rsync | |
parent | ee1f7349477f8438b234f6c8fa7f2d8f4cc00e6e (diff) |
Error out on memory failures in fargs_cmdline() and addargs() in both
cases it was impossible to start the remote rsync anyway. Also now
fargs_cmdline() can no longer fail. Add missing err(ERR_IPC, "pldege")
for the cases in socket.c
OK benno@
Diffstat (limited to 'usr.bin/rsync')
-rw-r--r-- | usr.bin/rsync/fargs.c | 9 | ||||
-rw-r--r-- | usr.bin/rsync/misc.c | 9 | ||||
-rw-r--r-- | usr.bin/rsync/socket.c | 11 |
3 files changed, 12 insertions, 17 deletions
diff --git a/usr.bin/rsync/fargs.c b/usr.bin/rsync/fargs.c index bb7123717d1..10eea6fa572 100644 --- a/usr.bin/rsync/fargs.c +++ b/usr.bin/rsync/fargs.c @@ -1,4 +1,4 @@ -/* $Id: fargs.c,v 1.17 2019/05/08 20:00:25 benno Exp $ */ +/* $Id: fargs.c,v 1.18 2021/05/17 12:02:58 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -17,6 +17,7 @@ #include <sys/stat.h> #include <assert.h> +#include <err.h> #include <stdint.h> #include <stdlib.h> #include <string.h> @@ -51,7 +52,7 @@ fargs_cmdline(struct sess *sess, const struct fargs *f, size_t *skip) if (sess->opts->ssh_prog) { ap = strdup(sess->opts->ssh_prog); if (ap == NULL) - goto out; + err(ERR_NOMEM, NULL); while ((arg = strsep(&ap, " \t")) != NULL) { if (arg[0] == '\0') { @@ -127,8 +128,4 @@ fargs_cmdline(struct sess *sess, const struct fargs *f, size_t *skip) addargs(&args, "%s", f->sink); return args.list; -out: - freeargs(&args); - ERR("calloc"); - return NULL; } diff --git a/usr.bin/rsync/misc.c b/usr.bin/rsync/misc.c index 95cba8b5aec..5abc7e039cf 100644 --- a/usr.bin/rsync/misc.c +++ b/usr.bin/rsync/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.2 2021/03/22 11:14:42 claudio Exp $ */ +/* $OpenBSD: misc.c,v 1.3 2021/05/17 12:02:58 claudio Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2005,2006 Damien Miller. All rights reserved. @@ -45,7 +45,7 @@ addargs(arglist *args, const char *fmt, ...) r = vasprintf(&cp, fmt, ap); va_end(ap); if (r == -1) - err(1, "addargs: argument too long"); + err(ERR_NOMEM, "addargs: argument too long"); nalloc = args->nalloc; if (args->list == NULL) { @@ -54,9 +54,10 @@ addargs(arglist *args, const char *fmt, ...) } else if (args->num+2 >= nalloc) nalloc *= 2; - args->list = recallocarray(args->list, args->nalloc, nalloc, sizeof(char *)); + args->list = recallocarray(args->list, args->nalloc, nalloc, + sizeof(char *)); if (!args->list) - err(1, "malloc"); + err(ERR_NOMEM, NULL); args->nalloc = nalloc; args->list[args->num++] = cp; args->list[args->num] = NULL; diff --git a/usr.bin/rsync/socket.c b/usr.bin/rsync/socket.c index f740c2dff2a..da58f5f2334 100644 --- a/usr.bin/rsync/socket.c +++ b/usr.bin/rsync/socket.c @@ -1,4 +1,4 @@ -/* $Id: socket.c,v 1.29 2021/03/31 19:45:16 job Exp $ */ +/* $Id: socket.c,v 1.30 2021/05/17 12:02:58 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -281,7 +281,7 @@ rsync_connect(const struct opts *opts, int *sd, const struct fargs *f) if (pledge("stdio unix rpath wpath cpath dpath inet fattr chown dns getpw unveil", NULL) == -1) - err(1, "pledge"); + err(ERR_IPC, "pledge"); memset(&sess, 0, sizeof(struct sess)); sess.opts = opts; @@ -365,7 +365,7 @@ rsync_socket(const struct opts *opts, int sd, const struct fargs *f) if (pledge("stdio unix rpath wpath cpath dpath fattr chown getpw unveil", NULL) == -1) - err(1, "pledge"); + err(ERR_IPC, "pledge"); memset(&sess, 0, sizeof(struct sess)); sess.lver = RSYNC_PROTOCOL; @@ -374,10 +374,7 @@ rsync_socket(const struct opts *opts, int sd, const struct fargs *f) assert(f->host != NULL); assert(f->module != NULL); - if ((args = fargs_cmdline(&sess, f, &skip)) == NULL) { - ERRX1("fargs_cmdline"); - exit(1); - } + args = fargs_cmdline(&sess, f, &skip); /* Initiate with the rsyncd version and module request. */ |