On Fri, Apr 20, 2012 at 07:36:46PM +0200, Jim Meyering wrote:
> From: Jim Meyering <[email protected]>
> 
> Given a zero-length directory name, the trailing-slash removal
> code would test dir_name[-1], and if it were found to be a slash,
> would set it to '\0'.
> ---
>  restore.c |    8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/restore.c b/restore.c
> index 250c9d3..f049105 100644
> --- a/restore.c
> +++ b/restore.c
> @@ -849,11 +849,9 @@ int main(int argc, char **argv)
>       strncpy(dir_name, argv[optind + 1], 128);
> 
>       /* Strip the trailing / on the dir name */
> -     while (1) {
> -             len = strlen(dir_name);
> -             if (dir_name[len - 1] != '/')
> -                     break;
> -             dir_name[len - 1] = '\0';
> +     len = strlen(dir_name);
> +     while (len && dir_name[--len] == '/')) {
> +             dir_name[len] = '\0';
>       }
> 
>       if (find_dir) {

Reviewed-by: Josef Bacik <[email protected]>

Thanks,

Josef
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to