#! /bin/sh /usr/share/dpatch/dpatch-run ## 10cfdisk.dpatch by LaMont Jones ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Buffer overruns with narrow terminal windows. @DPATCH@ diff -urNad util-linux/fdisk/cfdisk.c /tmp/dpep.rEB26p/util-linux/fdisk/cfdisk.c --- util-linux/fdisk/cfdisk.c 2004-12-24 14:41:20.000000000 -0700 +++ /tmp/dpep.rEB26p/util-linux/fdisk/cfdisk.c 2004-12-24 15:00:00.503453740 -0700 @@ -2100,7 +2100,7 @@ if (to_file) { if ((fp = fopen(fname, "w")) == NULL) { char errstr[LINE_LENGTH]; - sprintf(errstr, _("Cannot open file '%s'"), fname); + snprintf(errstr, sizeof(errstr), _("Cannot open file '%s'"), fname); print_warning(errstr); return; } @@ -2184,7 +2184,7 @@ if (to_file) { if ((fp = fopen(fname, "w")) == NULL) { char errstr[LINE_LENGTH]; - sprintf(errstr, _("Cannot open file '%s'"), fname); + snprintf(errstr, sizeof(errstr), _("Cannot open file '%s'"), fname); print_warning(errstr); return; } @@ -2638,9 +2638,9 @@ mvaddstr(WARNING_START, 0, line); - sprintf(line, "cfdisk %s", VERSION); + snprintf(line, COLS+1, "cfdisk %s", VERSION); mvaddstr(HEADER_START, (COLS-strlen(line))/2, line); - sprintf(line, _("Disk Drive: %s"), disk_device); + snprintf(line, COLS+1, _("Disk Drive: %s"), disk_device); mvaddstr(HEADER_START+2, (COLS-strlen(line))/2, line); { long long bytes = actual_size*(long long) SECTOR_SIZE; @@ -2654,7 +2654,7 @@ bytes, megabytes/K, (10*megabytes/K)%10); } mvaddstr(HEADER_START+3, (COLS-strlen(line))/2, line); - sprintf(line, _("Heads: %d Sectors per Track: %d Cylinders: %lld"), + snprintf(line, COLS+1, _("Heads: %d Sectors per Track: %d Cylinders: %lld"), heads, sectors, cylinders); mvaddstr(HEADER_START+4, (COLS-strlen(line))/2, line);