Message ID | 1531445105-18941-1-git-send-email-asmadeus@codewreck.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 7/12/18 7:25 PM, Dominique Martinet wrote: > Generated by scripts/coccinelle/misc/strncpy_truncation.cocci > > Signed-off-by: Dominique Martinet <asmadeus@codewreck.org> > --- > > Please see https://marc.info/?l=linux-kernel&m=153144450722324&w=2 (the > first patch of the serie) for the motivation behind this patch This is a weird combination in terms of a single patch, why is it patching aoe and gpiolib in one patch?
Jens Axboe wrote on Fri, Jul 13, 2018: > This is a weird combination in terms of a single patch, why is > it patching aoe and gpiolib in one patch? I must have failed some git add command, I didn't realize they were together until you pointed it out just now. This has been discussed more lengthly on the netdev side but the whole patch serie has been (quite) a bit too hasty; on one side I've been given some interesting feedback that I would not have gotten just sending the coccinelle patch first but I really should have waited for that to land first and most importantly spend more time on each individual patch, this was rude of me. I will make sure they are split in a v2, and send them individually (well, per big component) as self-explaining patches rather than as a block, once the coccinelle patch has been accepted. Thank you for the review,
diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c index 63773a90581d..1b2871056f8f 100644 --- a/drivers/block/aoe/aoenet.c +++ b/drivers/block/aoe/aoenet.c @@ -39,8 +39,7 @@ static struct ktstate kts; #ifndef MODULE static int __init aoe_iflist_setup(char *str) { - strncpy(aoe_iflist, str, IFLISTSZ); - aoe_iflist[IFLISTSZ - 1] = '\0'; + strlcpy(aoe_iflist, str, IFLISTSZ); return 1; } diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index e11a3bb03820..be08277699ff 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1015,12 +1015,10 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) memset(&chipinfo, 0, sizeof(chipinfo)); - strncpy(chipinfo.name, dev_name(&gdev->dev), + strlcpy(chipinfo.name, dev_name(&gdev->dev), sizeof(chipinfo.name)); - chipinfo.name[sizeof(chipinfo.name)-1] = '\0'; - strncpy(chipinfo.label, gdev->label, + strlcpy(chipinfo.label, gdev->label, sizeof(chipinfo.label)); - chipinfo.label[sizeof(chipinfo.label)-1] = '\0'; chipinfo.lines = gdev->ngpio; if (copy_to_user(ip, &chipinfo, sizeof(chipinfo))) return -EFAULT; @@ -1036,16 +1034,14 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) desc = &gdev->descs[lineinfo.line_offset]; if (desc->name) { - strncpy(lineinfo.name, desc->name, + strlcpy(lineinfo.name, desc->name, sizeof(lineinfo.name)); - lineinfo.name[sizeof(lineinfo.name)-1] = '\0'; } else { lineinfo.name[0] = '\0'; } if (desc->label) { - strncpy(lineinfo.consumer, desc->label, + strlcpy(lineinfo.consumer, desc->label, sizeof(lineinfo.consumer)); - lineinfo.consumer[sizeof(lineinfo.consumer)-1] = '\0'; } else { lineinfo.consumer[0] = '\0'; }
Generated by scripts/coccinelle/misc/strncpy_truncation.cocci Signed-off-by: Dominique Martinet <asmadeus@codewreck.org> --- Please see https://marc.info/?l=linux-kernel&m=153144450722324&w=2 (the first patch of the serie) for the motivation behind this patch drivers/block/aoe/aoenet.c | 3 +-- drivers/gpio/gpiolib.c | 12 ++++-------- 2 files changed, 5 insertions(+), 10 deletions(-)