From: Christian Brauner Date: Sat, 29 Oct 2016 11:29:26 +0000 (+0200) Subject: tools/lxc_console: use lxc_safe_uint() X-Git-Tag: lxc-2.1.0~257^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=31299e70d8fbf403afdd51ba7bed39203a6f3a11;p=thirdparty%2Flxc.git tools/lxc_console: use lxc_safe_uint() Signed-off-by: Christian Brauner --- diff --git a/src/lxc/arguments.h b/src/lxc/arguments.h index 78337485d..8ace559fb 100644 --- a/src/lxc/arguments.h +++ b/src/lxc/arguments.h @@ -61,7 +61,7 @@ struct lxc_arguments { const char *share_ns[32]; // size must be greater than LXC_NS_MAX /* for lxc-console */ - int ttynum; + unsigned int ttynum; char escape; /* for lxc-wait */ diff --git a/src/lxc/tools/lxc_console.c b/src/lxc/tools/lxc_console.c index 5d8dd4d0b..88a24bec3 100644 --- a/src/lxc/tools/lxc_console.c +++ b/src/lxc/tools/lxc_console.c @@ -22,29 +22,29 @@ */ #define _GNU_SOURCE -#include -#undef _GNU_SOURCE -#include #include -#include #include -#include -#include #include #include +#include +#include +#include +#include +#include +#include #include -#include #include -#include +#include #include +#include "arguments.h" +#include "commands.h" #include "error.h" -#include "lxc.h" #include "log.h" +#include "lxc.h" #include "mainloop.h" -#include "arguments.h" -#include "commands.h" +#include "utils.h" lxc_log_define(lxc_console_ui, lxc); @@ -58,8 +58,13 @@ static char etoc(const char *expr) static int my_parser(struct lxc_arguments* args, int c, char* arg) { switch (c) { - case 't': args->ttynum = atoi(arg); break; - case 'e': args->escape = etoc(arg); break; + case 't': + if (lxc_safe_uint(arg, &args->ttynum) < 0) + return -1; + break; + case 'e': + args->escape = etoc(arg); + break; } return 0; }