From: Jim Meyering Date: Thu, 26 Apr 2012 16:36:56 +0000 (+0200) Subject: Btrfs: NUL-terminate path buffer in DEV_INFO ioctl result X-Git-Tag: v3.12-rc1~2844^2~42^2~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a27202fbe92b12eec895c36644440175de01d7a6;p=kernel%2Fkernel-generic.git Btrfs: NUL-terminate path buffer in DEV_INFO ioctl result A device with name of length BTRFS_DEVICE_PATH_NAME_MAX or longer would not be NUL-terminated in the DEV_INFO ioctl result buffer. Signed-off-by: Jim Meyering --- diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 9ebb2c7..3d8ab27 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2263,10 +2263,12 @@ static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg) di_args->bytes_used = dev->bytes_used; di_args->total_bytes = dev->total_bytes; memcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid)); - if (dev->name) + if (dev->name) { strncpy(di_args->path, dev->name, sizeof(di_args->path)); - else + di_args->path[sizeof(di_args->path) - 1] = 0; + } else { di_args->path[0] = '\0'; + } out: if (ret == 0 && copy_to_user(arg, di_args, sizeof(*di_args)))