microcode_ctl/microcode_ctl-1.17-getopt.patch

24 lines
832 B
Diff
Raw Normal View History

diff -up microcode_ctl-1.17/microcode_ctl.c.getopt microcode_ctl-1.17/microcode_ctl.c
--- microcode_ctl-1.17/microcode_ctl.c.getopt 2011-12-22 13:15:55.073783568 +0100
+++ microcode_ctl-1.17/microcode_ctl.c 2011-12-22 13:14:22.000000000 +0100
@@ -151,7 +151,8 @@ int main(int argc, char *argv[])
break;
case 'd':
- strcpy(device, optarg);
+ strncpy(device, optarg, sizeof(device));
+ device[sizeof(device)-1] = '\0'; /* ensure null terminated */
break;
case 'u': /* do a microcode upload */
@@ -160,7 +161,8 @@ int main(int argc, char *argv[])
case 'f': /* set microcode file to optarg and upload */
upload++;
- strcpy(filename, optarg);
+ strncpy(filename, optarg, sizeof(filename));
+ filename[sizeof(filename)-1] = '\0'; /* ensure null terminated */
break;
case '?':