Package: parted
Version: 1.7.1-2.1
Severity: normal
Tags: patch
The header produced by the 'print' command is corrupted, as follows
(note the first two characters of what should be "Number"):
Disk /dev/hda: 60.0GB
Sector size (logical/physical): 512B/512B
Partition Table: mac
▒▒mber Start End Size File system Name Flags
This is due to the kfreebsd-gnu patch, which incorrectly assumes that it
can copy a pointer, realloc it, and then memcpy from the original
pointer. Since realloc is not guaranteed to move the pointer, or even
(as far as I can tell) not to overlap the new memory area with the
original, you need to duplicate the original string first and memcpy
from that. The attached patch does this.
Changelog entry:
* kfreebsd-gnu.dpatch: Fix memory corruption in table_render_row.
Thanks,
--
Colin Watson [EMAIL PROTECTED]
diff -u parted-1.7.1/debian/patches/kfreebsd-gnu.dpatch
parted-1.7.1/debian/patches/kfreebsd-gnu.dpatch
--- parted-1.7.1/debian/patches/kfreebsd-gnu.dpatch
+++ parted-1.7.1/debian/patches/kfreebsd-gnu.dpatch
@@ -1431,15 +1431,32 @@
diff -urNad parted-1.7.0~/parted/table.c parted-1.7.0/parted/table.c
--- parted-1.7.0~/parted/table.c 2006-05-19 03:54:01.000000000 -0300
+++ parted-1.7.0/parted/table.c 2006-05-19 03:54:36.000000000 -0300
-@@ -25,6 +25,7 @@
+@@ -23,22 +23,22 @@
+
+
++#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <assert.h>
-@@ -48,8 +49,24 @@
+ #include <config.h>
+
+ #ifdef ENABLE_NLS
+-# define _GNU_SOURCE
+ # include <wchar.h>
+ int wcswidth (const wchar_t *s, size_t n);
+ #else
+ # ifdef wchar_t
+ # undef wchar_t
+ # endif
+-# define _GNU_SOURCE
+ # include <string.h>
+ # define wchar_t char
+ # define wcslen strlen
+@@ -48,8 +48,24 @@
size_t strnlen (const char *, size_t);
#endif
@@ -1465,25 +1482,26 @@
static const unsigned int MAX_WIDTH = 512;
#ifdef ENABLE_NLS
-@@ -186,7 +203,8 @@
+@@ -186,7 +202,8 @@
{
wchar_t** row = t->rows[rownum];
int len = 1, i;
- size_t newsize;
+ size_t newsize, oldsize;
-+ wchar_t *temps;
++ wchar_t *temps;
assert(t);
assert(s != NULL);
-@@ -197,7 +215,11 @@
+@@ -197,7 +214,12 @@
len += wcslen(COLSUFFIX);
newsize = (wcslen(*s) + len + 1) * sizeof(wchar_t);
-+ oldsize = (wcslen(*s) + 1) * sizeof(wchar_t);
++ oldsize = (wcslen(*s) + 1) * sizeof(wchar_t);
+
-+ temps = *s;
++ temps = wcsdup(*s);
*s = realloc (*s, newsize);
-+ memcpy(*s, temps, oldsize);
++ memcpy(*s, temps, oldsize);
++ free(temps);
for (i = 0; i < ncols; ++i)
{