summaryrefslogtreecommitdiffstats
path: root/perl-install/resize_fat
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2000-04-14 15:11:57 +0000
committerFrancois Pons <fpons@mandriva.com>2000-04-14 15:11:57 +0000
commit21066f8c4d8d136cca65f7138cabb25d4b4cfe8c (patch)
treee51a023cbbbdea6ad22b962dc4e573603c67f31a /perl-install/resize_fat
parent3f3ced984833bf1084447c1afd3cfc7d17d0838b (diff)
downloaddrakx-backup-do-not-use-21066f8c4d8d136cca65f7138cabb25d4b4cfe8c.tar
drakx-backup-do-not-use-21066f8c4d8d136cca65f7138cabb25d4b4cfe8c.tar.gz
drakx-backup-do-not-use-21066f8c4d8d136cca65f7138cabb25d4b4cfe8c.tar.bz2
drakx-backup-do-not-use-21066f8c4d8d136cca65f7138cabb25d4b4cfe8c.tar.xz
drakx-backup-do-not-use-21066f8c4d8d136cca65f7138cabb25d4b4cfe8c.zip
*** empty log message ***
Diffstat (limited to 'perl-install/resize_fat')
-rw-r--r--perl-install/resize_fat/c_rewritten.xs31
-rw-r--r--perl-install/resize_fat/dir_entry.pm4
2 files changed, 25 insertions, 10 deletions
diff --git a/perl-install/resize_fat/c_rewritten.xs b/perl-install/resize_fat/c_rewritten.xs
index 33171c614..92361097d 100644
--- a/perl-install/resize_fat/c_rewritten.xs
+++ b/perl-install/resize_fat/c_rewritten.xs
@@ -23,7 +23,7 @@ unsigned int next(unsigned int cluster) {
free_all();
croak("fat::next: trying to use null pointer");
}
- if (cluster > nb_clusters + 2) {
+ if (cluster >= nb_clusters + 2) {
free_all();
croak("fat::next: cluster %d outside filesystem", cluster);
}
@@ -36,7 +36,7 @@ void set_next(unsigned int cluster, unsigned int val) {
free_all();
croak("fat::set_next: trying to use null pointer");
}
- if (cluster > nb_clusters + 2) {
+ if (cluster >= nb_clusters + 2) {
free_all();
croak("fat::set_next: cluster %d outside filesystem", cluster);
}
@@ -97,7 +97,7 @@ scan_fat(nb_clusters_, type_size_)
short *p;
type_size = type_size_; nb_clusters = nb_clusters_;
- bad_cluster_value = type_size == 32 ? 0xffffff7 : 0xfff7;
+ bad_cluster_value = type_size == 32 ? 0x0ffffff7 : 0xfff7;
if (type_size % 16) {
free_all();
@@ -162,7 +162,10 @@ checkFat(cluster, type, name)
free_all();
croak("Bad FAT: unterminated chain for %s\n", name);
}
-
+ if (cluster >= nb_clusters + 2) {
+ free_all();
+ croak("Bad FAT: chain outside filesystem for %s\n", name);
+ }
if (fat_flag_map[cluster]) {
free_all();
croak("Bad FAT: cluster %d is cross-linked for %s\n", cluster, name);
@@ -182,6 +185,10 @@ flag(cluster)
free_all();
croak("Bad FAT: trying to use null pointer");
}
+ if (cluster >= nb_clusters + 2) {
+ free_all();
+ croak("Bad FAT: going outside filesystem");
+ }
RETVAL = fat_flag_map[cluster];
OUTPUT:
RETVAL
@@ -195,6 +202,10 @@ set_flag(cluster, flag)
free_all();
croak("Bad FAT: trying to use null pointer");
}
+ if (cluster >= nb_clusters + 2) {
+ free_all();
+ croak("Bad FAT: going outside filesystem");
+ }
fat_flag_map[cluster] = flag;
void
@@ -219,10 +230,6 @@ fat_remap(cluster)
if (cluster >= bad_cluster_value) {
RETVAL = cluster; /* special cases */
} else {
- 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);
@@ -241,4 +248,12 @@ set_fat_remap(cluster, val)
free_all();
croak("set_fat_remap: trying to use null pointer");
}
+ if (cluster >= fat_remap_size) {
+ free_all();
+ croak("set_fat_remap: cluster %d >= %d in set_fat_remap", cluster, fat_remap_size);
+ }
+ if (val < bad_cluster_value && val >= fat_remap_size) {
+ free_all();
+ croak("set_fat_remap: remapping cluster %d to cluster %d >= %d in set_fat_remap", cluster, val, fat_remap_size);
+ }
fat_remap[cluster] = val;
diff --git a/perl-install/resize_fat/dir_entry.pm b/perl-install/resize_fat/dir_entry.pm
index 390659b0e..d944c04ac 100644
--- a/perl-install/resize_fat/dir_entry.pm
+++ b/perl-install/resize_fat/dir_entry.pm
@@ -17,7 +17,7 @@ my $DIRECTORY_ATTR = 0x10;
sub get_cluster($) {
my ($entry) = @_;
- $entry->{first_cluster} + ($resize_fat::isFAT32 ? $entry->{first_cluster_high} * 65536 : 0);
+ $entry->{first_cluster} + ($resize_fat::isFAT32 ? $entry->{first_cluster_high} * (1 << 16) : 0);
}
sub set_cluster($$) {
my ($entry, $val) = @_;
@@ -68,7 +68,7 @@ sub remap {
my $cluster = get_cluster($entry);
my $new_cluster = resize_fat::c_rewritten::fat_remap($cluster);
- #-print "remapping cluster ", get_first_cluster($fs, $entry), " to $new_cluster";
+ #-print "remapping cluster ", get_cluster($entry), " to $new_cluster";
$new_cluster == $cluster and return; #- no need to modify