diff -uprk.orig libfdisk0-20041101.orig/Makefile libfdisk0-20041101/Makefile --- libfdisk0-20041101.orig/Makefile 2004-11-09 15:03:30 +0300 +++ libfdisk0-20041101/Makefile 2004-12-24 19:18:58 +0300 @@ -1,6 +1,5 @@ # DEBUGFLAGS = -g -CFLAGS = -Wall $(DEBUGFLAGS) $(INCLUDEPATH) -D_GNU_SOURCE=1 -O -Os -fno-exceptions -fomit-frame-pointer -pipe -s -CFLAGS += -fPIC -Os -fno-exceptions -fomit-frame-pointer -pipe -s +CFLAGS = $(RPM_OPT_FLAGS) $(DEBUGFLAGS) $(INCLUDEPATH) -D_GNU_SOURCE=1 -fPIC LDFLAGS = $(LIBPATH) @@ -27,7 +26,7 @@ testfdisk: testfdisk.o $(LIBFDISK_SO) install: $(LIBFDISK_SO) install -d -m 755 $(DESTDIR)$(LIBDIR) install -d -m 755 $(DESTDIR)$(INCLUDEDIR)/libfdisk/ - install -s -m 755 $(LIBFDISK_SO) $(DESTDIR)$(LIBDIR) + install -p -m 755 $(LIBFDISK_SO) $(DESTDIR)$(LIBDIR) pushd $(DESTDIR)$(LIBDIR);ln -sf $(LIBFDISK_SO) libfdisk.so install -m 644 $(HEADERS) $(DESTDIR)$(INCLUDEDIR)/libfdisk/ diff -uprk.orig libfdisk0-20041101.orig/partition.c libfdisk0-20041101/partition.c --- libfdisk0-20041101.orig/partition.c 2004-11-01 17:06:13 +0300 +++ libfdisk0-20041101/partition.c 2004-12-24 19:41:04 +0300 @@ -553,6 +553,10 @@ int fdiskReadPartitions( HardDrive *hd ) fdiskSetAttrPartition( hd, i, &p ); } + memset(pt, 0, sizeof(*pt)); + free(pt); /* RawPartitionTable */ + pt = 0; + /* now pursue extended partition */ /* we do not handle more than one extended partition per drive */ /* read in extended partition(s) if they exist */ @@ -561,7 +565,6 @@ int fdiskReadPartitions( HardDrive *hd ) exttype = hd->table[i].type.current; if (fdiskIsExtended(exttype)) { - RawPartitionTable *extended; unsigned int ext_start; unsigned int ext_size; unsigned int cur_start; @@ -592,6 +595,8 @@ int fdiskReadPartitions( HardDrive *hd ) /* be using your OS's fdisk if this is the case, cause */ /* it is insane and only it can understand the madness */ while (1) { + RawPartitionTable *extended; + if ((s=fdiskReadPartitionTable(hd, cur_start, &extended))) return s; @@ -708,11 +713,15 @@ int fdiskReadPartitions( HardDrive *hd ) } /* see if we have another extended partition to follow */ - if (!sawext) + if (!sawext) { + memset(extended, 0, sizeof(*extended)); + free(extended); /* RawPartitionTable */ break; - else { + } else { cur_start = extended->entry[sawext-1].start + ext_start; cur_size = extended->entry[sawext-1].size; + memset(extended, 0, sizeof(*extended)); + free(extended); /* RawPartitionTable */ } } } diff -uprk.orig libfdisk0-20041101.orig/partspec.c libfdisk0-20041101/partspec.c --- libfdisk0-20041101.orig/partspec.c 2000-02-28 09:04:43 +0300 +++ libfdisk0-20041101/partspec.c 2004-12-24 19:46:15 +0300 @@ -237,8 +237,7 @@ int fdiskDeletePartitionSpec( PartitionS if (spec->entry[j].partition.immutable) return FDISK_ERR_BADNUM; - if (spec->entry[j].name) - free(spec->entry[j].name); + free(spec->entry[j].name); for (k=j; k < spec->num-1; k++) memcpy(&spec->entry[k], &spec->entry[k+1], sizeof(PartitionSpecEntry)); @@ -255,10 +254,12 @@ int fdiskWipePartitionSpec( PartitionSpe unsigned int i; for (i=0; i<spec->num; i++) + { free(spec->entry[i].name); + memset(&spec->entry[i], 0, sizeof(PartitionSpecEntry)); + } memset(spec, 0, sizeof(PartitionSpec)); - spec->num = 0; return FDISK_SUCCESS; } @@ -326,8 +327,7 @@ int fdiskCleanOriginalSpecs( HardDrive * } if (remove) { - if (spec->entry[j].name) - free(spec->entry[j].name); + free(spec->entry[j].name); for (k=j; k < spec->num-1; k++) memcpy(&spec->entry[k], &spec->entry[k+1], sizeof(PartitionSpecEntry)); @@ -350,6 +350,8 @@ int fdiskSetupPartitionSpec( HardDrive * Partition *p; char *name; + memset(spec, 0, sizeof(*spec)); + /* make sure there are any partitions to process */ status = 0; for (i=0; i<numhd; i++) diff -uprk.orig libfdisk0-20041101.orig/rawio.c libfdisk0-20041101/rawio.c --- libfdisk0-20041101.orig/rawio.c 2004-11-01 17:08:32 +0300 +++ libfdisk0-20041101/rawio.c 2004-12-24 19:18:49 +0300 @@ -181,7 +181,8 @@ int fdiskReadPartitionTable(HardDrive *h return FDISK_ERR_BADMAGIC; t = (RawPartitionTable *) malloc(sizeof(RawPartitionTable)); - + memset(t, 0, sizeof(RawPartitionTable)); + for (i=0; i<4; i++){ memcpy( &t->entry[i], b+PARTTBLOFF+i*sizeof(RawPartition),