Skip to content
Snippets Groups Projects
Commit 02460447 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Fix SAUCE date properly... avoid writing past the end of the buffer

parent 3de37030
No related branches found
No related tags found
No related merge requests found
Pipeline #6741 passed
...@@ -2270,14 +2270,12 @@ capture_control(struct bbslist *bbs) ...@@ -2270,14 +2270,12 @@ capture_control(struct bbslist *bbs)
memcpy(sauce.author, bbs->user, memcpy(sauce.author, bbs->user,
MIN(strlen(bbs->user), sizeof(sauce.author))); MIN(strlen(bbs->user), sizeof(sauce.author)));
} }
if ((tm = localtime(&t)) != NULL) { // The null-terminator if ((tm = localtime(&t)) != NULL) {
// overwrites the first char tmpstr[SAUCE_LEN_DATE + 1] = {0};
// byte of filesize if (snprintf(tmpstr, sizeof(tmpstr), "%04u%02u%02u",
// We can't use snprintf() here because snprintf() 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday) >= 0) {
// Is guaranteed to terminate, so the last digit memcpy(sauce.date, tmpstr, SAUCE_LEN_DATE);
// would always be truncated. }
sprintf(sauce.date, "%04u%02u%02u",
1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday);
} }
sauce.filesize = LE_INT32(ftell(fp)); // LE sauce.filesize = LE_INT32(ftell(fp)); // LE
sauce.datatype = sauce_datatype_bin; sauce.datatype = sauce_datatype_bin;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment