mirror of
https://github.com/Tha14/toxic.git
synced 2025-07-06 09:26:44 +02:00
more thorough error checking
This commit is contained in:
@ -224,9 +224,25 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
|
||||
return;
|
||||
}
|
||||
|
||||
fseek(file_to_send, 0, SEEK_END);
|
||||
if (fseek(file_to_send, 0, SEEK_END) == -1) {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "File corrupt.");
|
||||
fclose(file_to_send);
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t filesize = ftell(file_to_send);
|
||||
fseek(file_to_send, 0, SEEK_SET);
|
||||
|
||||
if (filesize == -1) {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "File corrupt.");
|
||||
fclose(file_to_send);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fseek(file_to_send, 0, SEEK_SET) == -1) {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "File corrupt.");
|
||||
fclose(file_to_send);
|
||||
return;
|
||||
}
|
||||
|
||||
char filename[MAX_STR_SIZE] = {0};
|
||||
get_file_name(filename, sizeof(filename), path);
|
||||
@ -235,6 +251,7 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
|
||||
|
||||
if (filenum == -1) {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Error sending file.");
|
||||
fclose(file_to_send);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user