[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug #18530] Sparc SIGBUS in md5 routines
From: |
Mark D. Baushke |
Subject: |
Re: [bug #18530] Sparc SIGBUS in md5 routines |
Date: |
Mon, 18 Dec 2006 20:25:41 -0800 |
I have applied this patch to the FEATURE branch which will eventually
become 1.12.14.
ChangeLog entry:
* cvs.h (checksum_t): New typedef union for md5 checksum
alignment.
* client.c (stored_checksum, handle_checksum, update_entires):
Use it.
* update.c (update_fileproc): Ditto.
(struct patch_file_data): Use bool for compute_checksum flag.
(patch_file): Update compute_checksum assignments to bool.
Index: src/client.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/client.c,v
retrieving revision 1.460
diff -u -p -r1.460 client.c
--- src/client.c 26 Jul 2006 09:52:56 -0000 1.460
+++ src/client.c 19 Dec 2006 04:14:48 -0000
@@ -1278,7 +1278,7 @@ static time_t last_register_time;
* it here, and then check it in update_entries.
*/
static int stored_checksum_valid;
-static unsigned char stored_checksum[16];
+static checksum_t stored_ck; /* sixteen bytes for MD5 checksum */
static void
handle_checksum (char *args, size_t len)
{
@@ -1297,7 +1297,7 @@ handle_checksum (char *args, size_t len)
buf[0] = *s++;
buf[1] = *s++;
- stored_checksum[i] = (char) strtol (buf, &bufend, 16);
+ stored_ck.char_checksum[i] = (unsigned char) strtol (buf, &bufend, 16);
if (bufend != buf + 2)
break;
}
@@ -1705,13 +1705,13 @@ update_entries (void *data_arg, List *en
{
if (stored_checksum_valid)
{
- unsigned char checksum[16];
+ checksum_t ck;
/* We have a checksum. Check it before writing
the file out, so that we don't have to read it
back in again. */
- md5_buffer (patchedbuf, patchedlen, checksum);
- if (memcmp (checksum, stored_checksum, 16) != 0)
+ md5_buffer (patchedbuf, patchedlen, ck.char_checksum);
+ if (memcmp (ck.char_checksum, stored_ck.char_checksum, 16)
!= 0)
{
error (0, 0,
"checksum failure after patch to `%s'; will refetch",
@@ -1752,7 +1752,7 @@ update_entries (void *data_arg, List *en
struct md5_ctx context;
unsigned char buf[8192];
unsigned len;
- unsigned char checksum[16];
+ checksum_t ck;
/*
* Compute the MD5 checksum. This will normally only be
@@ -1773,13 +1773,13 @@ update_entries (void *data_arg, List *en
md5_process_bytes (buf, len, &context);
if (ferror (e))
error (1, errno, "could not read %s", short_pathname);
- md5_finish_ctx (&context, checksum);
+ md5_finish_ctx (&context, ck.char_checksum);
fclose (e);
stored_checksum_valid = 0;
- if (memcmp (checksum, stored_checksum, 16) != 0)
+ if (memcmp (ck.char_checksum, stored_ck.char_checksum, 16) != 0)
{
if (data->contents != UPDATE_ENTRIES_PATCH)
error (1, 0, "checksum failure on %s",
Index: src/cvs.h
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/cvs.h,v
retrieving revision 1.350
diff -u -p -r1.350 cvs.h
--- src/cvs.h 2 Sep 2006 23:18:00 -0000 1.350
+++ src/cvs.h 19 Dec 2006 04:14:48 -0000
@@ -601,3 +601,8 @@ extern const char *global_session_id;
/* From find_names.c. */
List *find_files (const char *dir, const char *pat);
+
+typedef union {
+ uint32_t int_checksum[4];
+ unsigned char char_checksum[16];
+} checksum_t;
Index: src/update.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/update.c,v
retrieving revision 1.266
diff -u -p -r1.266 update.c
--- src/update.c 24 Aug 2006 18:36:27 -0000 1.266
+++ src/update.c 19 Dec 2006 04:14:50 -0000
@@ -742,11 +742,11 @@ update_fileproc (void *callerdat, struct
{
int docheckout;
struct stat file_info;
- unsigned char checksum[16];
+ checksum_t ck;
retval = patch_file (finfo,
vers, &docheckout,
- &file_info, checksum);
+ &file_info, ck.char_checksum);
if (!docheckout)
{
if (retval == 0)
@@ -754,7 +754,8 @@ update_fileproc (void *callerdat, struct
(rcs_diff_patches
? SERVER_RCS_DIFF
: SERVER_PATCHED),
- file_info.st_mode, checksum,
+ file_info.st_mode,
+ ck.char_checksum,
NULL);
break;
}
@@ -1472,7 +1473,7 @@ struct patch_file_data
/* File to which to write. */
FILE *fp;
/* Whether to compute the MD5 checksum. */
- int compute_checksum;
+ bool compute_checksum;
/* Data structure for computing the MD5 checksum. */
struct md5_ctx context;
/* Set if the file has a final newline. */
@@ -1567,7 +1568,7 @@ patch_file (struct file_info *finfo, Ver
data.filename = file1;
data.fp = e;
data.final_nl = 0;
- data.compute_checksum = 0;
+ data.compute_checksum = false;
/* Duplicating the client working file, so use the original sticky options.
*/
@@ -1591,7 +1592,7 @@ patch_file (struct file_info *finfo, Ver
data.filename = file2;
data.fp = e;
data.final_nl = 0;
- data.compute_checksum = 1;
+ data.compute_checksum = true;
md5_init_ctx (&data.context);
retcode = RCS_checkout (vers_ts->srcfile, NULL,