diff options
Diffstat (limited to 'drivers/parisc/pdc_stable.c')
-rw-r--r-- | drivers/parisc/pdc_stable.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c index 0f54ab6260df..3651c3871d5b 100644 --- a/drivers/parisc/pdc_stable.c +++ b/drivers/parisc/pdc_stable.c | |||
@@ -278,7 +278,7 @@ pdcspath_hwpath_write(struct pdcspath_entry *entry, const char *buf, size_t coun | |||
278 | { | 278 | { |
279 | struct hardware_path hwpath; | 279 | struct hardware_path hwpath; |
280 | unsigned short i; | 280 | unsigned short i; |
281 | char in[count+1], *temp; | 281 | char in[64], *temp; |
282 | struct device *dev; | 282 | struct device *dev; |
283 | int ret; | 283 | int ret; |
284 | 284 | ||
@@ -286,8 +286,9 @@ pdcspath_hwpath_write(struct pdcspath_entry *entry, const char *buf, size_t coun | |||
286 | return -EINVAL; | 286 | return -EINVAL; |
287 | 287 | ||
288 | /* We'll use a local copy of buf */ | 288 | /* We'll use a local copy of buf */ |
289 | memset(in, 0, count+1); | 289 | count = min_t(size_t, count, sizeof(in)-1); |
290 | strncpy(in, buf, count); | 290 | strncpy(in, buf, count); |
291 | in[count] = '\0'; | ||
291 | 292 | ||
292 | /* Let's clean up the target. 0xff is a blank pattern */ | 293 | /* Let's clean up the target. 0xff is a blank pattern */ |
293 | memset(&hwpath, 0xff, sizeof(hwpath)); | 294 | memset(&hwpath, 0xff, sizeof(hwpath)); |
@@ -393,14 +394,15 @@ pdcspath_layer_write(struct pdcspath_entry *entry, const char *buf, size_t count | |||
393 | { | 394 | { |
394 | unsigned int layers[6]; /* device-specific info (ctlr#, unit#, ...) */ | 395 | unsigned int layers[6]; /* device-specific info (ctlr#, unit#, ...) */ |
395 | unsigned short i; | 396 | unsigned short i; |
396 | char in[count+1], *temp; | 397 | char in[64], *temp; |
397 | 398 | ||
398 | if (!entry || !buf || !count) | 399 | if (!entry || !buf || !count) |
399 | return -EINVAL; | 400 | return -EINVAL; |
400 | 401 | ||
401 | /* We'll use a local copy of buf */ | 402 | /* We'll use a local copy of buf */ |
402 | memset(in, 0, count+1); | 403 | count = min_t(size_t, count, sizeof(in)-1); |
403 | strncpy(in, buf, count); | 404 | strncpy(in, buf, count); |
405 | in[count] = '\0'; | ||
404 | 406 | ||
405 | /* Let's clean up the target. 0 is a blank pattern */ | 407 | /* Let's clean up the target. 0 is a blank pattern */ |
406 | memset(&layers, 0, sizeof(layers)); | 408 | memset(&layers, 0, sizeof(layers)); |
@@ -755,7 +757,7 @@ static ssize_t pdcs_auto_write(struct kobject *kobj, | |||
755 | { | 757 | { |
756 | struct pdcspath_entry *pathentry; | 758 | struct pdcspath_entry *pathentry; |
757 | unsigned char flags; | 759 | unsigned char flags; |
758 | char in[count+1], *temp; | 760 | char in[8], *temp; |
759 | char c; | 761 | char c; |
760 | 762 | ||
761 | if (!capable(CAP_SYS_ADMIN)) | 763 | if (!capable(CAP_SYS_ADMIN)) |
@@ -765,8 +767,9 @@ static ssize_t pdcs_auto_write(struct kobject *kobj, | |||
765 | return -EINVAL; | 767 | return -EINVAL; |
766 | 768 | ||
767 | /* We'll use a local copy of buf */ | 769 | /* We'll use a local copy of buf */ |
768 | memset(in, 0, count+1); | 770 | count = min_t(size_t, count, sizeof(in)-1); |
769 | strncpy(in, buf, count); | 771 | strncpy(in, buf, count); |
772 | in[count] = '\0'; | ||
770 | 773 | ||
771 | /* Current flags are stored in primary boot path entry */ | 774 | /* Current flags are stored in primary boot path entry */ |
772 | pathentry = &pdcspath_entry_primary; | 775 | pathentry = &pdcspath_entry_primary; |