add a few checks

This commit is contained in:
Andrew Pamment 2019-12-02 10:20:16 +10:00
parent b13769e1fc
commit 575ff1f2b9

View File

@ -183,12 +183,12 @@ void md_exit(int exitcode) {
exit(exitcode); exit(exitcode);
} }
int md_init(const char *dropfile, int socket) { void md_init(const char *dropfile, int socket) {
char *filename = strrchr(dropfile, PATH_SEP); char *filename = strrchr(dropfile, PATH_SEP);
#if !defined(WIN32) && !defined(_MSC_VER) #if !defined(WIN32) && !defined(_MSC_VER)
struct termios ttystate; struct termios ttystate;
#endif #endif
int ret; int ret = -1;
mdcontrol.socket = socket; mdcontrol.socket = socket;
@ -202,6 +202,14 @@ int md_init(const char *dropfile, int socket) {
ret = read_doorsys(dropfile); ret = read_doorsys(dropfile);
} else if (strcasecmp(filename, "door32.sys") == 0) { } else if (strcasecmp(filename, "door32.sys") == 0) {
ret = read_door32(dropfile); ret = read_door32(dropfile);
} else {
fprintf(stderr, "Unsupported dropfile: %s\n", filename);
exit(-1);
}
if (ret == -1) {
fprintf(stderr, "Unable to open dropfile: %s\n", dropfile);
exit(-1);
} }
if (mdcontrol.socket == -1) { if (mdcontrol.socket == -1) {