[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/9] ui: Check numeric part of expire_password argument @time pro
From: |
Markus Armbruster |
Subject: |
[PATCH 1/9] ui: Check numeric part of expire_password argument @time properly |
Date: |
Thu, 1 Dec 2022 07:13:03 +0100 |
When argument @time isn't 'now' or 'never', we parse it as an integer,
optionally prefixed with '+'. If parsing fails, we silently assume
zero. Report an error and fail instead.
While there, use qemu_strtou64() instead of strtoull() so
checkpatch.pl won't complain.
Aside: encoding numbers in strings is bad QMP practice.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
monitor/qmp-cmds.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index 81c8fdadf8..054d7648b1 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -205,15 +205,28 @@ void qmp_expire_password(ExpirePasswordOptions *opts,
Error **errp)
time_t when;
int rc;
const char *whenstr = opts->time;
+ const char *numstr = NULL;
+ uint64_t num;
if (strcmp(whenstr, "now") == 0) {
when = 0;
} else if (strcmp(whenstr, "never") == 0) {
when = TIME_MAX;
} else if (whenstr[0] == '+') {
- when = time(NULL) + strtoull(whenstr+1, NULL, 10);
+ when = time(NULL);
+ numstr = whenstr + 1;
} else {
- when = strtoull(whenstr, NULL, 10);
+ when = 0;
+ numstr = whenstr;
+ }
+
+ if (numstr) {
+ if (qemu_strtou64(numstr, NULL, 10, &num) < 0) {
+ error_setg(errp, "Parameter 'time' doesn't take value '%s'",
+ whenstr);
+ return;
+ }
+ when += num;
}
if (opts->protocol == DISPLAY_PROTOCOL_SPICE) {
--
2.37.3
- [PATCH 3/9] ui: Drop disabled code for SPICE_CHANNEL_WEBDAV, (continued)
- [PATCH 3/9] ui: Drop disabled code for SPICE_CHANNEL_WEBDAV, Markus Armbruster, 2022/12/01
- Re: [PATCH 3/9] ui: Drop disabled code for SPICE_CHANNEL_WEBDAV, Daniel P . Berrangé, 2022/12/01
- Re: [PATCH 3/9] ui: Drop disabled code for SPICE_CHANNEL_WEBDAV, Markus Armbruster, 2022/12/01
- Re: [PATCH 3/9] ui: Drop disabled code for SPICE_CHANNEL_WEBDAV, Markus Armbruster, 2022/12/01
- Re: [PATCH 3/9] ui: Drop disabled code for SPICE_CHANNEL_WEBDAV, Daniel P . Berrangé, 2022/12/01
- Re: [PATCH 3/9] ui: Drop disabled code for SPICE_CHANNEL_WEBDAV, Markus Armbruster, 2022/12/01
- Re: [PATCH 3/9] ui: Drop disabled code for SPICE_CHANNEL_WEBDAV, Daniel P . Berrangé, 2022/12/01
- Re: [PATCH 3/9] ui: Drop disabled code for SPICE_CHANNEL_WEBDAV, Markus Armbruster, 2022/12/02
[PATCH 4/9] ui: Clean up a few things checkpatch.pl would flag later on, Markus Armbruster, 2022/12/01
[PATCH 1/9] ui: Check numeric part of expire_password argument @time properly,
Markus Armbruster <=
[PATCH 2/9] ui: Fix silent truncation of numeric keys in HMP sendkey, Markus Armbruster, 2022/12/01
[PATCH 7/9] ui: Improve "change vnc" error reporting, Markus Armbruster, 2022/12/01
[PATCH 8/9] ui: Factor out hmp_change_vnc(), and move to ui/ui-hmp-cmds.c, Markus Armbruster, 2022/12/01
[PATCH 6/9] ui: Move HMP commands from monitor to new ui/ui-hmp-cmds.c, Markus Armbruster, 2022/12/01