]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
tools/lxc_console: use lxc_safe_uint()
authorChristian Brauner <christian.brauner@canonical.com>
Sat, 29 Oct 2016 11:29:26 +0000 (13:29 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 22 Nov 2016 04:59:37 +0000 (23:59 -0500)
Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
src/lxc/arguments.h
src/lxc/tools/lxc_console.c

index 4e7591ff1665b6ad177c44a6e90934a33eebb682..c00f0a215d37ca62d1d9a8a1ce359ed7858dad64 100644 (file)
@@ -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 */
index 5d8dd4d0be1aec346db0cd3559bb8765ca34d0b8..88a24bec3fda94f713341dfae00a0ec0c7a44636 100644 (file)
  */
 
 #define _GNU_SOURCE
-#include <stdio.h>
-#undef _GNU_SOURCE
-#include <stdlib.h>
 #include <errno.h>
-#include <string.h>
 #include <fcntl.h>
-#include <unistd.h>
-#include <signal.h>
 #include <libgen.h>
 #include <poll.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
 #include <sys/param.h>
-#include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/ioctl.h>
+#include <sys/types.h>
 
 #include <lxc/lxccontainer.h>
 
+#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;
 }