[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] PATCH: block-vvfat.c: fix parse_long_name
From: |
Johannes Schindelin |
Subject: |
Re: [Qemu-devel] PATCH: block-vvfat.c: fix parse_long_name |
Date: |
Wed, 2 Jul 2008 15:05:50 +0100 (BST) |
User-agent: |
Alpine 1.00 (DEB 882 2007-12-20) |
Hi,
seems that your patches always force me to go to the source to see why
they are correct. In particular, I had to check that...
On Wed, 2 Jul 2008, Tristan Gingold wrote:
> --- block-vvfat.c (revision 4820)
> +++ block-vvfat.c (working copy)
> @@ -1435,6 +1435,7 @@
> lfn->sequence_number = pointer[0] & 0x3f;
> lfn->checksum = pointer[13];
> lfn->name[0] = 0;
> + lfn->name[lfn->sequence_number * 13] = 0;
... did not access unallocated memory.
I had to verify myself (which I assume every reviewer would have to do,
since you did not explain the particulars in your mail) that lfn->name is
a char[1024] buffer, and therefore large enough, since 0x3f * 13 = 819 <
1024.
Now, I think that this patch should be accompanied with this:
-- snipsnap --
[PATCH] block-vvfat: adjust long files' name length to theoretical maximum
Since the sequence number can be at most 0x3f, and the file name length
only 13 times as much, we do not need to allocate 1024 bytes, but only
820 per long file name.
Signed-off-by: Johannes Schindelin <address@hidden>
---
block-vvfat.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/block-vvfat.c b/block-vvfat.c
index a93fde9..54f6bb5 100644
--- a/block-vvfat.c
+++ b/block-vvfat.c
@@ -1411,7 +1411,12 @@ static void schedule_mkdir(BDRVVVFATState* s, uint32_t
cluster, char* path)
}
typedef struct {
- unsigned char name[1024];
+ /*
+ * Since the sequence number is at most 0x3f, and the file length is
+ * at most 13 times the sequence number, the maximal file length is
+ * 0x3f * 13 bytes.
+ */
+ unsigned char name[0x3f * 13 + 1];
int checksum, len;
int sequence_number;
} long_file_name;