fixed a couple of minor bugs

pull/11/head
John Tsiombikas 2020-05-26 01:45:01 +03:00
rodzic c9aa215c24
commit 4edd00de1c
2 zmienionych plików z 5 dodań i 6 usunięć

9
back.c
Wyświetl plik

@ -102,13 +102,12 @@ int get_daemon_pid(void)
fprintf(stderr, "no spacenav pid file, can't find daemon\n");
return -1;
}
fgets(buf, sizeof buf, fp);
fclose(fp);
if(!isdigit(buf[0])) {
fprintf(stderr, "fucked up pidfile, can't find daemon\n");
if(!fgets(buf, sizeof buf, fp) || !isdigit(buf[0])) {
fprintf(stderr, "corrupted pidfile, can't find the daemon\n");
fclose(fp);
return -1;
}
fclose(fp);
return atoi(buf);
}

Wyświetl plik

@ -250,7 +250,7 @@ int read_cfg(const char *fname, struct cfg *cfg)
}
} else if(strcmp(key_str, "serial") == 0) {
strncpy(cfg->serial_dev, val_str, PATH_MAX);
strncpy(cfg->serial_dev, val_str, PATH_MAX - 1);
} else {
fprintf(stderr, "unrecognized config option: %s\n", key_str);