microcode_ctl/microcode_ctl-1.17-getopt.patch
Anton Arapov ae1d259eb6 fix buffer overflow, bug 768803
Signed-off-by: Anton Arapov <anton@redhat.com>
2011-12-22 13:59:24 +01:00

24 lines
832 B
Diff

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 '?':