2001-11-29 01:39:28 UTC
The attached patch corrects an alignment problem on
SPARC processors. The original version may access
i64 values that are not aligned at 8 byte
boundaries if the value of ptr is not a multiple of
8 in read_pfile. On a SPARC (and probably HP-PA
and Alpha as well), unaligned access triggers a
segmentation violation.
-- mva
--- rwpar.c.orig Sat Nov 17 21:20:09 2001
+++ rwpar.c Thu Nov 29 02:21:15 2001
@@ -225,21 +225,20 @@
read_pfile(pfile_t *file, u8 *ptr, u16 *path, i64 pl)
{
i64 i, l;
- pfile_entr_t *pf;
-
- pf = ((pfile_entr_t *)ptr);
-
- i = read_i64(&pf->size);
- file->status = read_i64(&pf->status);
- file->file_size = read_i64(&pf->file_size);
- COPY(file->hash, pf->hash, sizeof(md5));
- COPY(file->hash_16k, pf->hash_16k, sizeof(md5));
+ pfile_entr_t pf;
+
+ COPY(&pf, ptr, 1);
+ i = read_i64(&pf.size);
+ file->status = read_i64(&pf.status);
+ file->file_size = read_i64(&pf.file_size);
+ COPY(file->hash, pf.hash, sizeof(md5));
+ COPY(file->hash_16k, pf.hash_16k, sizeof(md5));
l = (i - FILE_ENTRY_FIX_SIZE) / 2;
NEW(file->filename, pl + l + 1);
COPY(file->filename, path, pl);
- read_u16s(file->filename + pl, &pf->filename, l);
+ read_u16s(file->filename + pl, &pf.filename, l);
file->filename[l + pl] = 0;
-
+ COPY(ptr, &pf, 1);
return i;
}