view toys/pending/deallocvt.c @ 1294:88abd5b68a17 draft

dhcp client had a segfault, when DHCP message contained 'pad' option. The parsing logic kept checking for other options beyond __pad__ option, without checking if it was __end__ option after that or not.
author Ashwini Sharma <ak.ashwini1981@gmail.com>
date Wed, 21 May 2014 05:12:38 -0500
parents 3c855d5a75be
children
line wrap: on
line source

/* deallocvt.c - Deallocate virtual terminal(s)
 *
 * Copyright 2014 Vivek Kumar Bhagat <vivek.bhagat89@gmail.com>
 *
 * No Standard.

USE_DEALLOCVT(NEWTOY(deallocvt, ">1", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_NEEDROOT))

config DEALLOCVT
  bool "deallocvt"
  depends on OPENVT
  default n
  help
    usage: deallocvt [N]

    Deallocate unused virtual terminal /dev/ttyN
    default value of N is 0, deallocate all unused consoles
*/

#include "toys.h"
#include <linux/vt.h>

void deallocvt_main(void)
{
  int fd;

  // 0 : deallocate all unused consoles
  int vt_num = 0;

  if (toys.optargs[0])
    vt_num = atolx_range(toys.optargs[0], 1, 63);

  fd = find_console_fd();
  if (fd < 0)  error_exit("can't open console");

  xioctl(fd, VT_DISALLOCATE, (void *)(ptrdiff_t)vt_num);
}