]> git.ipfire.org Git - thirdparty/git.git/commitdiff
reftable: fix OOB stack write in print functions
authorHan-Wen Nienhuys <hanwen@google.com>
Thu, 20 Jan 2022 15:12:00 +0000 (15:12 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Jan 2022 19:31:52 +0000 (11:31 -0800)
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reftable/record.c

index 6a5dac32dc69b7187d8c4e9481e6ddbe058ccae2..8536bd03aa9ea36033992b7430cc80678f3ffc03 100644 (file)
@@ -254,7 +254,7 @@ static void hex_format(char *dest, uint8_t *src, int hash_size)
 void reftable_ref_record_print(struct reftable_ref_record *ref,
                               uint32_t hash_id)
 {
-       char hex[2 * GIT_SHA256_RAWSZ + 1] = { 0 }; /* BUG */
+       char hex[GIT_MAX_HEXSZ + 1] = { 0 }; /* BUG */
        printf("ref{%s(%" PRIu64 ") ", ref->refname, ref->update_index);
        switch (ref->value_type) {
        case REFTABLE_REF_SYMREF:
@@ -586,7 +586,7 @@ static struct reftable_record_vtable reftable_obj_record_vtable = {
 void reftable_log_record_print(struct reftable_log_record *log,
                               uint32_t hash_id)
 {
-       char hex[GIT_SHA256_RAWSZ + 1] = { 0 };
+       char hex[GIT_MAX_HEXSZ + 1] = { 0 };
 
        switch (log->value_type) {
        case REFTABLE_LOG_DELETION: