Re: [PATCH v7 01/16] reftable: fix OOB stack write in print functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 24 2022, Han-Wen Nienhuys via GitGitGadget wrote:

> From: Han-Wen Nienhuys <hanwen@xxxxxxxxxx>
>
> Remove /* BUG */ comment, whose meaning has escaped my memory.
>
> Signed-off-by: Han-Wen Nienhuys <hanwen@xxxxxxxxxx>
> ---
>  reftable/record.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/reftable/record.c b/reftable/record.c
> index 6a5dac32dc6..1f236b47d1c 100644
> --- a/reftable/record.c
> +++ b/reftable/record.c
> @@ -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];
>  	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:

FWIW it seems to originate from
https://github.com/hanwen/reftable/commit/62bbd28 and first appeared
on-list in
https://lore.kernel.org/git/pull.847.v4.git.git.1607522429.gitgitgadget@xxxxxxxxx/
(i.e. any /SHA.*BUG/ in this code). Probably just in reference to having
to hardcode the "2 * " and/or SHA256 which later/now is using a more
generic macro.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux