Download raw body.
Fix strftime(3) short buffer checks
Noticed this on the rebase/histedit -l patch. Most likely copy pasted from elsewhere in the code. Let's fix it everywhere. ----------------------------------------------- commit e046e6534160944f0b817685836911e37c93cbde (strftime) from: Josh Rickmar <jrick@companyzero.com> date: Sun Mar 21 17:28:36 2021 UTC Fix strftime(3) short buffer checks strftime(3) returns 0 if the buffer was too short to write the complete string (including NUL) and will never return more than maxsize-1. diff 37e57951d24c69f2d56ab41065a2d5563d8174cb c40cf9c87952e14a1ebf8751b147f2c2f30102bd blob - 9bcd279e5446ef8a890025dd5e3e16b3206fc66a blob + 5a81fddc99d43b6d16f047c9a6ade37e0058f4e6 --- got/got.c +++ got/got.c @@ -4570,7 +4570,7 @@ blame_cb(void *arg, int nlines, int lineno, struct got if (localtime_r(&committer_time, &tm) == NULL) return got_error_from_errno("localtime_r"); if (strftime(bline->datebuf, sizeof(bline->datebuf), "%G-%m-%d", - &tm) >= sizeof(bline->datebuf)) { + &tm) == 0) { err = got_error(GOT_ERR_NO_SPACE); goto done; } @@ -10073,7 +10073,7 @@ print_path_info(void *arg, const char *path, mode_t mo tm = localtime_r(&mtime, &mytm); if (tm == NULL) return NULL; - if (strftime(datebuf, sizeof(datebuf), "%c %Z", tm) >= sizeof(datebuf)) + if (strftime(datebuf, sizeof(datebuf), "%c %Z", tm) == 0) return got_error(GOT_ERR_NO_SPACE); printf("timestamp: %s\n", datebuf); blob - 5251b5a0c5366a6290eb08871fc51273ed568885 blob + 3b1cd05a35ea3d8b66188660baf875aca5f0f005 --- gotweb/gotweb.c +++ gotweb/gotweb.c @@ -3821,7 +3821,7 @@ gw_blame_cb(void *arg, int nlines, int lineno, struct if (localtime_r(&committer_time, &tm) == NULL) return got_error_from_errno("localtime_r"); if (strftime(bline->datebuf, sizeof(bline->datebuf), "%G-%m-%d", - &tm) >= sizeof(bline->datebuf)) { + &tm) == 0) { err = got_error(GOT_ERR_NO_SPACE); goto done; } blob - 66c10afc613515bfc9122f54ffacf6671ce45f67 blob + c426e9d11b25926d3d473cea50910a6e8ecd3240 --- tog/tog.c +++ tog/tog.c @@ -1343,8 +1343,7 @@ draw_commit(struct tog_view *view, struct got_commit_o committer_time = got_object_commit_get_committer_time(commit); if (localtime_r(&committer_time, &tm) == NULL) return got_error_from_errno("localtime_r"); - if (strftime(datebuf, sizeof(datebuf), "%G-%m-%d ", &tm) - >= sizeof(datebuf)) + if (strftime(datebuf, sizeof(datebuf), "%G-%m-%d ", &tm) == 0) return got_error(GOT_ERR_NO_SPACE); if (avail <= date_display_cols)
Fix strftime(3) short buffer checks