Fix error in "last all" command and several -Wunused-result compiler errors (#55)
* Add build generated files to .gitignore * Fix error in "last all" output and resolve Wunused-result warnings - Check return value of several standard library calls that could return error states. - Fix issue with "last all" command (it sent tabs for alignment that were reinterpreted as colors). * Fix buffer overflow in do_export_zone command
This commit is contained in:
34
src/boards.c
34
src/boards.c
@@ -464,14 +464,33 @@ void board_load_board(int board_type)
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < num_of_msgs[board_type]; i++) {
|
||||
fread(&(msg_index[board_type][i]), sizeof(struct board_msginfo), 1, fl);
|
||||
if (fread(&(msg_index[board_type][i]), sizeof(struct board_msginfo), 1, fl) != 1) {
|
||||
if (feof(fl))
|
||||
log("SYSERR: Unexpected EOF encountered in board file %d! Resetting.", board_type);
|
||||
else if (ferror(fl))
|
||||
log("SYSERR: Error reading board file %d: %s. Resetting.", board_type, strerror(errno));
|
||||
else
|
||||
log("SYSERR: Error reading board file %d. Resetting.", board_type);
|
||||
board_reset_board(board_type);
|
||||
}
|
||||
if ((len1 = msg_index[board_type][i].heading_len) <= 0) {
|
||||
log("SYSERR: Board file %d corrupt! Resetting.", board_type);
|
||||
board_reset_board(board_type);
|
||||
return;
|
||||
}
|
||||
|
||||
CREATE(tmp1, char, len1);
|
||||
fread(tmp1, sizeof(char), len1, fl);
|
||||
|
||||
if (fread(tmp1, sizeof(char), len1, fl) != len1) {
|
||||
if (feof(fl))
|
||||
log("SYSERR: Unexpected EOF encountered in board file %d! Resetting.", board_type);
|
||||
else if (ferror(fl))
|
||||
log("SYSERR: Error reading board file %d: %s. Resetting.", board_type, strerror(errno));
|
||||
else
|
||||
log("SYSERR: Error reading board file %d. Resetting.", board_type);
|
||||
board_reset_board(board_type);
|
||||
}
|
||||
|
||||
MSG_HEADING(board_type, i) = tmp1;
|
||||
|
||||
if ((MSG_SLOTNUM(board_type, i) = find_slot()) == -1) {
|
||||
@@ -481,7 +500,16 @@ void board_load_board(int board_type)
|
||||
}
|
||||
if ((len2 = msg_index[board_type][i].message_len) > 0) {
|
||||
CREATE(tmp2, char, len2);
|
||||
fread(tmp2, sizeof(char), len2, fl);
|
||||
if (fread(tmp2, sizeof(char), len2, fl) != sizeof(char) * len2) {
|
||||
if (feof(fl))
|
||||
log("SYSERR: Unexpected EOF encountered in board file %d! Resetting.", board_type);
|
||||
else if (ferror(fl))
|
||||
log("SYSERR: Error reading board file %d: %s. Resetting.", board_type, strerror(errno));
|
||||
else
|
||||
log("SYSERR: Error reading board file %d. Resetting.", board_type);
|
||||
board_reset_board(board_type);
|
||||
}
|
||||
|
||||
msg_storage[MSG_SLOTNUM(board_type, i)] = tmp2;
|
||||
} else
|
||||
msg_storage[MSG_SLOTNUM(board_type, i)] = NULL;
|
||||
|
||||
Reference in New Issue
Block a user