The Samba-Bugzilla – Attachment 7168 Details for
Bug 8654
link-by-hash: Fix (non-exploitable) buffer overflow
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Improve generation of hash file name
0001-Improve-generation-of-hash-file-name.patch (text/plain), 1.50 KB, created by
Chris Dunlop
on 2011-12-12 03:07:19 UTC
(
hide
)
Description:
Improve generation of hash file name
Filename:
MIME Type:
Creator:
Chris Dunlop
Created:
2011-12-12 03:07:19 UTC
Size:
1.50 KB
patch
obsolete
>From 783113e0bd020f0e7653d62c82fda5c34d472fb8 Mon Sep 17 00:00:00 2001 >From: Chris Dunlop <chris@onthe.net.au> >Date: Mon, 12 Dec 2011 14:04:25 +1100 >Subject: [PATCH] Improve generation of hash file name > >Use the calculated checksum_len rather than assuming 16 bytes. > >Use sprintf() rather than hand-rolled binary-to-text. This is not in a >critical performance path. Note: this same sprintf() method is used in >checksum-updating.diff. > >Signed-off-by: Chris Dunlop <chris@onthe.net.au> >--- > hashlink.c | 15 +++++---------- > 1 files changed, 5 insertions(+), 10 deletions(-) > >diff --git a/hashlink.c b/hashlink.c >index 12cc39b..55433bc 100644 >--- a/hashlink.c >+++ b/hashlink.c >@@ -21,6 +21,7 @@ > #include "rsync.h" > > extern char *link_by_hash_dir; >+extern int checksum_len; > > #ifdef HAVE_LINK > >@@ -30,18 +31,12 @@ char *make_hash_name(struct file_struct *file) > uchar c, *src = (uchar*)F_SUM(file); > int i; > >- for (dst = hash, i = 0; i < 4; i++, src++) { >- c = *src >> 4; >- *(dst++) = (c >= 10) ? (c - 10 + 'a') : (c + '0'); >- c = *src & 0x0f; >- *(dst++) = (c >= 10) ? (c - 10 + 'a') : (c + '0'); >+ for (dst = hash, i = 0; i < 4; i++, src++, dst += 2) { >+ sprintf(dst, "%02x", (int)CVAL(src, 0)); > } > *dst++ = '/'; >- for (i = 0; i < 12; i++, src++) { >- c = *src >> 4; >- *(dst++) = (c >= 10) ? (c - 10 + 'a') : (c + '0'); >- c = *src & 0x0f; >- *(dst++) = (c >= 10) ? (c - 10 + 'a') : (c + '0'); >+ for ( ; i < checksum_len; i++, src++, dst += 2) { >+ sprintf(dst, "%02x", (int)CVAL(src, 0)); > } > *dst = 0; > >-- >1.7.0.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 8654
:
7167
|
7168
|
7169
|
7170
|
7173
|
7174
|
7175
|
7176
|
7177
|
7202