qemu-devel
[Top][All Lists]
Advanced

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

Re: [PULL v2 5/5] 9pfs: Fix segfault in do_readdir_many caused by struct


From: Peter Maydell
Subject: Re: [PULL v2 5/5] 9pfs: Fix segfault in do_readdir_many caused by struct dirent overread
Date: Tue, 22 Feb 2022 13:21:52 +0000

On Thu, 17 Feb 2022 at 16:43, Christian Schoenebeck
<qemu_oss@crudebyte.com> wrote:
> diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
> index d1660d67fa..ce12f64853 100644
> --- a/include/qemu/osdep.h
> +++ b/include/qemu/osdep.h
> @@ -805,6 +805,19 @@ static inline int platform_does_not_support_system(const 
> char *command)
>  }
>  #endif /* !HAVE_SYSTEM_FUNCTION */
>
> +/**
> + * Duplicate directory entry @dent.
> + *
> + * It is highly recommended to use this function instead of open coding
> + * duplication of @c dirent objects, because the actual @c struct @c dirent
> + * size may be bigger or shorter than @c sizeof(struct dirent) and correct
> + * handling is platform specific (see gitlab issue #841).
> + *
> + * @dent - original directory entry to be duplicated
> + * @returns duplicated directory entry which should be freed with g_free()
> + */
> +struct dirent *qemu_dirent_dup(struct dirent *dent);

Hi; I just noticed this has landed in git recently.
Please don't add new prototypes to osdep.h -- it is
a header included by every single C file in the tree, so
making it bigger slows down compilation. osdep.h is supposed
to contain only:
 * things which everybody needs
 * things without which code would work on most platforms but
   fail to compile or misbehave on a minority of host OSes
   (ie system incompatibility handling)

This prototype is neither of those -- please find or create a more
appropriate header file for it, that can be included only by the
source files that actually need it.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]