commit ec6d1a368f4f81cda70f8517eb0dec5028b847b8 from: Josh Rickmar date: Sun Mar 21 18:49:57 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. ok stsp commit - 4e20a6488836bfbb096ecad1bad212e094cc8624 commit + ec6d1a368f4f81cda70f8517eb0dec5028b847b8 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)