Skip to content

Commit

Permalink
tools/lxc_console: use lxc_safe_uint()
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
  • Loading branch information
Christian Brauner authored and stgraber committed Nov 22, 2016
1 parent 4efa4bb commit 89154b8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/lxc/arguments.h
Expand Up @@ -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 */
Expand Down
31 changes: 18 additions & 13 deletions src/lxc/tools/lxc_console.c
Expand Up @@ -22,29 +22,29 @@
*/

#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);

Expand All @@ -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;
}
Expand Down

0 comments on commit 89154b8

Please sign in to comment.