int main(int argc, char** argv)
{
+ int ret;
+
if (geteuid() != 0) {
cap_t caps = cap_get_proc();
cap_flag_value_t capfv;
/* Check arguments */
if (argc != 2) {
printf("No arguments given, assuming that \"/dev/input/event0\" is the keyboard.\n");
- evdev_path = "/dev/input/event0";
- } else {
- evdev_path = malloc(strlen(argv[1])*sizeof(char) + 1);
- strcpy(evdev_path, argv[1]);
+ ret = asprintf(&evdev_path, "/dev/input/event0");
+ } else
+ ret = asprintf(&evdev_path, "%s", argv[1]);
+ if (ret < 0) {
+ fprintf(stderr, "CRTITICAL: Cannot set up event device path\n");
+ return -1;
}
/* Setup threading data */