Re: [PATCH] xfs_scrub: fix buffer overflow in string_escape

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

 



On 2025-02-20 14:07:58, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@xxxxxxxxxx>
> 
> Need to allocate one more byte for the null terminator, just in case the
> /entire/ input string consists of non-printable bytes e.g. emoji.
> 
> Cc: <linux-xfs@xxxxxxxxxxxxxxx> # v4.15.0
> Fixes: 396cd0223598bb ("xfs_scrub: warn about suspicious characters in directory/xattr names")
> Signed-off-by: "Darrick J. Wong" <djwong@xxxxxxxxxx>
> ---
>  scrub/common.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scrub/common.c b/scrub/common.c
> index 6eb3c026dc5ac9..7ea0277bc511ce 100644
> --- a/scrub/common.c
> +++ b/scrub/common.c
> @@ -320,7 +320,7 @@ string_escape(
>  	char			*q;
>  	int			x;
>  
> -	str = malloc(strlen(in) * 4);
> +	str = malloc((strlen(in) * 4) + 1);
>  	if (!str)
>  		return NULL;
>  	for (p = in, q = str; *p != '\0'; p++) {
> 

Looks good to me
Reviewed-by: Andrey Albershteyn <aalbersh@xxxxxxxxxx>

-- 
- Andrey





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux