bug-hurd
[Top][All Lists]
Advanced

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

Re: [PATCH 3/3] libdiskfs: fix string termination


From: Samuel Thibault
Subject: Re: [PATCH 3/3] libdiskfs: fix string termination
Date: Tue, 25 Mar 2014 02:09:25 +0100
User-agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30)

Justus Winter, le Thu 20 Mar 2014 14:01:20 +0100, a écrit :
> Found using the Clang Static Analyzer.
> 
> * libdiskfs/fsys-getroot.c (diskfs_S_fsys_getroot): Fix string
> termination.

Ack.

> ---
>  libdiskfs/fsys-getroot.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/libdiskfs/fsys-getroot.c b/libdiskfs/fsys-getroot.c
> index 5212214..10793c8 100644
> --- a/libdiskfs/fsys-getroot.c
> +++ b/libdiskfs/fsys-getroot.c
> @@ -101,15 +101,17 @@ diskfs_S_fsys_getroot (struct diskfs_control *pt,
>      {
>        /* Handle symlink interpretation */
>        char pathbuf[diskfs_root_node->dn_stat.st_size + 1];
> -      size_t amt;
>  
>        if (diskfs_read_symlink_hook)
>       err = (*diskfs_read_symlink_hook) (diskfs_root_node, pathbuf);
>        if (!diskfs_read_symlink_hook || err == EINVAL)
> -     err = diskfs_node_rdwr (diskfs_root_node, pathbuf, 0,
> +     {
> +       size_t amt = 0;
> +       err = diskfs_node_rdwr (diskfs_root_node, pathbuf, 0,
>                                 diskfs_root_node->dn_stat.st_size, 0,
>                                 0, &amt);
> -      pathbuf[amt] = '\0';
> +       pathbuf[amt] = '\0';
> +     }
>  
>        pthread_mutex_unlock (&diskfs_root_node->lock);
>        pthread_rwlock_unlock (&diskfs_fsys_lock);
> -- 
> 1.9.0
> 

-- 
Samuel
<d> bah à défaut de ligne TGV, ils ont un GR
 -+- #ens-mim - comment ça, paumé ?! -+-



reply via email to

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