From 563f5dda3f2b9efdd6751044f6fe94fad33c7541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Tue, 26 Oct 2010 08:59:51 +0200 Subject: [PATCH] Implemented a basic check on upcase table --- libntfs-3g/volume.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libntfs-3g/volume.c b/libntfs-3g/volume.c index 629ec92c..5c5ac774 100644 --- a/libntfs-3g/volume.c +++ b/libntfs-3g/volume.c @@ -868,6 +868,7 @@ ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, unsigned long flags) VOLUME_INFORMATION *vinf; ntfschar *vname; int i, j, eo; + unsigned int k; u32 u; vol = ntfs_volume_startup(dev, flags); @@ -1025,6 +1026,17 @@ ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, unsigned long flags) ntfs_log_perror("Failed to close $UpCase"); goto error_exit; } + /* Consistency check of $UpCase, restricted to plain ASCII chars */ + k = 0x20; + while ((k < vol->upcase_len) + && (k < 0x7f) + && (le16_to_cpu(vol->upcase[k]) + == ((k < 'a') || (k > 'z') ? k : k + 'A' - 'a'))) + k++; + if (k < 0x7f) { + ntfs_log_perror("Corrupted file $UpCase"); + goto error_exit; + } /* * Now load $Volume and set the version information and flags in the