summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2000-04-11 15:15:23 +0000
committerFrancois Pons <fpons@mandriva.com>2000-04-11 15:15:23 +0000
commitdec0bdbb64a662c2276fcca1afb3e069143990ac (patch)
tree8d1778b11a51c0a200e04c18962a0cb6b04101eb
parentde19160a9fc5d7021ce5b9ab516e5af72b3f394e (diff)
downloaddrakx-dec0bdbb64a662c2276fcca1afb3e069143990ac.tar
drakx-dec0bdbb64a662c2276fcca1afb3e069143990ac.tar.gz
drakx-dec0bdbb64a662c2276fcca1afb3e069143990ac.tar.bz2
drakx-dec0bdbb64a662c2276fcca1afb3e069143990ac.tar.xz
drakx-dec0bdbb64a662c2276fcca1afb3e069143990ac.zip
*** empty log message ***
-rw-r--r--perl-install/ChangeLog5
-rw-r--r--perl-install/install_steps_interactive.pm2
-rw-r--r--perl-install/interactive_gtk.pm4
-rw-r--r--perl-install/resize_fat/any.pm2
-rw-r--r--perl-install/resize_fat/boot_sector.pm2
-rw-r--r--perl-install/resize_fat/c_rewritten.xs100
-rw-r--r--perl-install/resize_fat/main.pm2
7 files changed, 95 insertions, 22 deletions
diff --git a/perl-install/ChangeLog b/perl-install/ChangeLog
index b7df29278..324746da4 100644
--- a/perl-install/ChangeLog
+++ b/perl-install/ChangeLog
@@ -1,3 +1,8 @@
+2000-04-11 François Pons <fpons@mandrakesoft.com>
+
+ * resize_fat: added some limits verification.
+ * interactive_gtk.pm: corrected swap of arg with help adding.
+
2000-04-10 François Pons <fpons@mandrakesoft.com>
* interactive_gtk.pm, my_gtk.pm: added tooltips for ask_from_list,
diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm
index 7d5069ce5..52d9c4fb1 100644
--- a/perl-install/install_steps_interactive.pm
+++ b/perl-install/install_steps_interactive.pm
@@ -161,7 +161,7 @@ sub selectMouse {
$o->SUPER::selectMouse;
}
#------------------------------------------------------------------------------
-sub setupSCSI {
+sub setupSCSI {
my ($o) = @_;
{ my $w = $o->wait_message(_("IDE"), _("Configuring IDE"));
modules::load_ide() }
diff --git a/perl-install/interactive_gtk.pm b/perl-install/interactive_gtk.pm
index 7202b96ac..979220dd8 100644
--- a/perl-install/interactive_gtk.pm
+++ b/perl-install/interactive_gtk.pm
@@ -149,11 +149,11 @@ sub ask_from_treelistW {
sub ask_many_from_list_refW {
my ($o, $title, $messages, $list, $val) = @_;
- ask_many_from_list_with_help_refW($o, $title, $messages, undef, $list, $val)
+ ask_many_from_list_with_help_refW($o, $title, $messages, $list, undef, $val)
}
sub ask_many_from_list_with_help_refW {
- my ($o, $title, $messages, $help, $list, $val) = @_;
+ my ($o, $title, $messages, $list, $help, $val) = @_;
my $w = my_gtk->new('', %$o);
my $tips = new Gtk::Tooltips;
my $box = gtkpack(new Gtk::VBox(0,0),
diff --git a/perl-install/resize_fat/any.pm b/perl-install/resize_fat/any.pm
index 63f154008..407159437 100644
--- a/perl-install/resize_fat/any.pm
+++ b/perl-install/resize_fat/any.pm
@@ -27,7 +27,7 @@ sub min_cluster_count($) {
}
sub max_cluster_count($) {
my ($fs) = @_;
- 2 ** $fs->{fs_type_size} - 11;
+ (1 << $ {{ FAT16 => 16, FAT32 => 28 }}{$fs->{fs_type}}) - 11;
}
diff --git a/perl-install/resize_fat/boot_sector.pm b/perl-install/resize_fat/boot_sector.pm
index dbfc33830..294f93a97 100644
--- a/perl-install/resize_fat/boot_sector.pm
+++ b/perl-install/resize_fat/boot_sector.pm
@@ -75,7 +75,7 @@ sub read($) {
$fs->{nb_root_dir_entries} = 0;
$fs->{info_offset} = $fs->{info_offset_in_sectors} * $fs->{sector_size};
- $resize_fat::bad_cluster_value = 0xffffff7;
+ $resize_fat::bad_cluster_value = 0x0ffffff7;
}
$fs->{fat_offset} = $fs->{nb_reserved} * $fs->{sector_size};
diff --git a/perl-install/resize_fat/c_rewritten.xs b/perl-install/resize_fat/c_rewritten.xs
index eb3e314dd..33171c614 100644
--- a/perl-install/resize_fat/c_rewritten.xs
+++ b/perl-install/resize_fat/c_rewritten.xs
@@ -9,15 +9,37 @@ unsigned int *fat_remap = NULL;
int fat_remap_size;
int type_size, nb_clusters, bad_cluster_value;
+void free_all() {
+#define FREE(p) if (p) free(p), p = NULL;
+ FREE(fat);
+ FREE(fat_flag_map);
+ FREE(fat_remap);
+#undef FREE
+}
+
unsigned int next(unsigned int cluster) {
short *p = fat + type_size * cluster;
- if (cluster > nb_clusters + 2) croak("fat::next: cluster %d outside filesystem", cluster);
+ if (!fat) {
+ free_all();
+ croak("fat::next: trying to use null pointer");
+ }
+ if (cluster > nb_clusters + 2) {
+ free_all();
+ croak("fat::next: cluster %d outside filesystem", cluster);
+ }
return type_size == 1 ? *p : *((unsigned int *) p);
}
void set_next(unsigned int cluster, unsigned int val) {
short *p = fat + type_size * cluster;
- if (cluster > nb_clusters + 2) croak("fat::set_next: cluster %d outside filesystem", cluster);
+ if (!fat) {
+ free_all();
+ croak("fat::set_next: trying to use null pointer");
+ }
+ if (cluster > nb_clusters + 2) {
+ free_all();
+ croak("fat::set_next: cluster %d outside filesystem", cluster);
+ }
type_size == 1 ? *p : *((unsigned int *) p) = val;
}
@@ -32,13 +54,17 @@ read_fat(fd, offset, size, magic)
PPCODE:
{
fat = (short *) malloc(size);
+ if (!fat) {
+ free_all();
+ croak("read_fat: not enough memory");
+ }
if (lseek(fd, offset, SEEK_SET) != offset ||
read(fd, fat, size) != size) {
- free(fat); fat = NULL;
+ free_all();
croak("read_fat: reading FAT failed");
}
if (magic != *(unsigned char *) fat) {
- free(fat); fat = NULL;
+ free_all();
croak("read_fat: FAT has invalid signature");
}
}
@@ -49,17 +75,16 @@ write_fat(fd, size)
int size
PPCODE:
{
- if (write(fd, fat, size) != size) croak("write_fat: write failed");
+ if (write(fd, fat, size) != size) {
+ free_all();
+ croak("write_fat: write failed");
+ }
}
void
free_all()
PPCODE:
-#define FREE(p) if (p) free(p), p = NULL;
- FREE(fat);
- FREE(fat_flag_map);
- FREE(fat_remap);
-#undef FREE
+ free_all();
void
scan_fat(nb_clusters_, type_size_)
@@ -74,7 +99,10 @@ scan_fat(nb_clusters_, type_size_)
type_size = type_size_; nb_clusters = nb_clusters_;
bad_cluster_value = type_size == 32 ? 0xffffff7 : 0xfff7;
- if (type_size % 16) croak("scan_fat: unable to handle FAT%d", type_size);
+ if (type_size % 16) {
+ free_all();
+ croak("scan_fat: unable to handle FAT%d", type_size);
+ }
type_size /= 16;
for (p = fat + 2 * type_size; p < fat + type_size * (nb_clusters + 2); p += type_size) {
@@ -112,6 +140,10 @@ allocate_fat_flag(size)
int size
CODE:
fat_flag_map = calloc(size, 1);
+ if (!fat_flag_map) {
+ free_all();
+ croak("allocate_fat_flag: not enough memory");
+ }
int
checkFat(cluster, type, name)
@@ -121,10 +153,20 @@ checkFat(cluster, type, name)
CODE:
int nb = 0;
+ if (!fat_flag_map) {
+ free_all();
+ croak("Bad FAT: trying to use null pointer");
+ }
for (; cluster < bad_cluster_value; cluster = next(cluster)) {
- if (cluster == 0) croak("Bad FAT: unterminated chain for %s\n", name);
-
- if (fat_flag_map[cluster]) croak("Bad FAT: cluster %d is cross-linked for %s\n", cluster, name);
+ if (cluster == 0) {
+ free_all();
+ croak("Bad FAT: unterminated chain for %s\n", name);
+ }
+
+ if (fat_flag_map[cluster]) {
+ free_all();
+ croak("Bad FAT: cluster %d is cross-linked for %s\n", cluster, name);
+ }
fat_flag_map[cluster] = type;
nb++;
}
@@ -136,6 +178,10 @@ unsigned int
flag(cluster)
unsigned int cluster
CODE:
+ if (!fat_flag_map) {
+ free_all();
+ croak("Bad FAT: trying to use null pointer");
+ }
RETVAL = fat_flag_map[cluster];
OUTPUT:
RETVAL
@@ -145,6 +191,10 @@ set_flag(cluster, flag)
unsigned int cluster
int flag
CODE:
+ if (!fat_flag_map) {
+ free_all();
+ croak("Bad FAT: trying to use null pointer");
+ }
fat_flag_map[cluster] = flag;
void
@@ -153,16 +203,30 @@ allocate_fat_remap(size)
CODE:
fat_remap_size = size;
fat_remap = (unsigned int *) calloc(size, sizeof(unsigned int *));
+ if (!fat_remap) {
+ free_all();
+ croak("allocate_fat_remap: not enough memory");
+ }
unsigned int
fat_remap(cluster)
unsigned int cluster
CODE:
+ if (!fat_remap) {
+ free_all();
+ croak("fat_remap: trying to use null pointer");
+ }
if (cluster >= bad_cluster_value) {
RETVAL = cluster; /* special cases */
} else {
- if (fat_remap == NULL) croak("fat_remap: NULL in fat_remap");
- if (cluster >= fat_remap_size) croak("fat_remap: cluster %d >= %d in fat_remap", cluster, fat_remap_size);
+ if (fat_remap == NULL) {
+ free_all();
+ croak("fat_remap: NULL in fat_remap");
+ }
+ if (cluster >= fat_remap_size) {
+ free_all();
+ croak("fat_remap: cluster %d >= %d in fat_remap", cluster, fat_remap_size);
+ }
RETVAL = fat_remap[cluster];
}
OUTPUT:
@@ -173,4 +237,8 @@ set_fat_remap(cluster, val)
unsigned int cluster
unsigned int val
CODE:
+ if (!fat_remap) {
+ free_all();
+ croak("set_fat_remap: trying to use null pointer");
+ }
fat_remap[cluster] = val;
diff --git a/perl-install/resize_fat/main.pm b/perl-install/resize_fat/main.pm
index c2e589e74..0c94586ec 100644
--- a/perl-install/resize_fat/main.pm
+++ b/perl-install/resize_fat/main.pm
@@ -130,7 +130,7 @@ sub resize {
$size >= $min or die "Minimum filesystem size is $min sectors";
$size <= $max or die "Maximum filesystem size is $max sectors";
- log::l("resize_fat: Partition size will be ", $size >> 11, "Mb (well exactly ${size} sectors)");
+ log::l("resize_fat: Partition size will be ". ($size * $SECTORSIZE >> 20) ."Mb (well exactly ${size} sectors)");
my $new_data_size = $size * $SECTORSIZE - $fs->{cluster_offset};
my $new_nb_clusters = divide($new_data_size, $fs->{cluster_size});