aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/cutils.c13
-rw-r--r--util/error.c8
-rw-r--r--util/qemu-option.c2
3 files changed, 15 insertions, 8 deletions
diff --git a/util/cutils.c b/util/cutils.c
index b337293..dbe7412 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -24,6 +24,8 @@
#include "qemu-common.h"
#include "qemu/host-utils.h"
#include <math.h>
+#include <limits.h>
+#include <errno.h>
#include "qemu/sockets.h"
#include "qemu/iov.h"
@@ -457,11 +459,16 @@ int parse_uint_full(const char *s, unsigned long long *value, int base)
int qemu_parse_fd(const char *param)
{
- int fd;
- char *endptr = NULL;
+ long fd;
+ char *endptr;
+ errno = 0;
fd = strtol(param, &endptr, 10);
- if (*endptr || (fd == 0 && param == endptr)) {
+ if (param == endptr /* no conversion performed */ ||
+ errno != 0 /* not representable as long; possibly others */ ||
+ *endptr != '\0' /* final string not empty */ ||
+ fd < 0 /* invalid as file descriptor */ ||
+ fd > INT_MAX /* not representable as int */) {
return -1;
}
return fd;
diff --git a/util/error.c b/util/error.c
index 2bb42e1..66245cc 100644
--- a/util/error.c
+++ b/util/error.c
@@ -165,13 +165,13 @@ void error_free(Error *err)
}
}
-void error_propagate(Error **dst_err, Error *local_err)
+void error_propagate(Error **dst_errp, Error *local_err)
{
- if (local_err && dst_err == &error_abort) {
+ if (local_err && dst_errp == &error_abort) {
error_report("%s", error_get_pretty(local_err));
abort();
- } else if (dst_err && !*dst_err) {
- *dst_err = local_err;
+ } else if (dst_errp && !*dst_errp) {
+ *dst_errp = local_err;
} else if (local_err) {
error_free(local_err);
}
diff --git a/util/qemu-option.c b/util/qemu-option.c
index 8bbc3ad..324e4c5 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -1036,7 +1036,7 @@ static void qemu_opts_from_qdict_1(const char *key, QObject *obj, void *opaque)
const char *value;
int n;
- if (!strcmp(key, "id") || error_is_set(state->errp)) {
+ if (!strcmp(key, "id") || *state->errp) {
return;
}