1 diff -ur rpm-5.4.10/build/files.c rpm-5.4.10-collision/build/files.c
2 --- rpm-5.4.10/build/files.c 2013-03-17 13:17:38.233358389 +0100
3 +++ rpm-5.4.10-collision/build/files.c 2013-03-17 13:07:37.468483625 +0100
8 +static int isHardLink(FileListRec flp, FileListRec tlp)
10 + return ((S_ISREG(flp->fl_mode) && S_ISREG(tlp->fl_mode)) &&
11 + ((flp->fl_nlink > 1) && (flp->fl_nlink == tlp->fl_nlink)) &&
12 + (flp->fl_ino == tlp->fl_ino) &&
13 + (flp->fl_dev == tlp->fl_dev));
16 +static int seenHardLink(FileList fl, FileListRec flp, ino_t *fileid)
19 + for (ilp = fl->fileList; ilp < flp; ilp++) {
20 + if (isHardLink(flp, ilp)) {
21 + *fileid = ilp - fl->fileList;
29 * Add file entries to header.
30 * @todo Should directories have %doc/%config attributes? (#14531)
33 for (i = 0, flp = fl->fileList; i < fl->fileListRecsUsed; i++, flp++) {
35 + ino_t fileid = flp - fl->fileList;
37 /* Merge duplicate entries. */
38 while (i < (fl->fileListRecsUsed - 1) &&
39 @@ -1437,6 +1458,13 @@
40 /* Leave room for both dirname and basename NUL's */
41 dpathlen += (strlen(flp->diskURL) + 2);
43 + /* Excludes and dupes have been filtered out by now. */
44 + if (S_ISREG(flp->fl_mode)) {
45 + if (flp->fl_nlink == 1 || !seenHardLink(fl, flp, &fileid)) {
46 + fl->totalFileSize += flp->fl_size;
51 * Make the header, the OLDFILENAMES will get converted to a
52 * compressed file list write before we write the actual package to
53 @@ -1519,7 +1547,11 @@
55 /* XXX Hash instead of 64b->32b truncate to prevent aliasing. */
56 { ino_t _ino = flp->fl_ino;
57 - ui32 = hashFunctionString(0, &_ino, sizeof(_ino));
58 + /* don't use hash here, as hash collisions which happen on large packages
59 + cause bus errors in rpmbuild
60 + ui32 = hashFunctionString(0, &_ino, sizeof(_ino));
64 he->tag = RPMTAG_FILEINODES;
65 he->t = RPM_UINT32_TYPE;
66 @@ -1752,39 +1780,6 @@
67 IOSM_MAP_TYPE | IOSM_MAP_MODE | IOSM_MAP_UID | IOSM_MAP_GID;
69 fi->fmapflags[i] |= IOSM_FOLLOW_SYMLINKS;
71 - if (S_ISREG(flp->fl_mode)) {
73 - /* Hard links need be tallied only once. */
74 - if (flp->fl_nlink > 1) {
75 - FileListRec jlp = flp + 1;
77 - for (; (unsigned)j < fi->fc; j++, jlp++) {
78 - /* follow outer loop logic */
79 - while (((jlp - fl->fileList) < (fl->fileListRecsUsed - 1)) &&
80 - !strcmp(jlp->fileURL, jlp[1].fileURL))
82 - if (jlp->flags & RPMFILE_EXCLUDE) {
84 - /*@innercontinue@*/ continue;
86 - if (jlp->flags & RPMFILE_GHOST)
87 - /*@innercontinue@*/ continue;
88 - if (!S_ISREG(jlp->fl_mode))
89 - /*@innercontinue@*/ continue;
90 - if (flp->fl_nlink != jlp->fl_nlink)
91 - /*@innercontinue@*/ continue;
92 - if (flp->fl_ino != jlp->fl_ino)
93 - /*@innercontinue@*/ continue;
94 - if (flp->fl_dev != jlp->fl_dev)
95 - /*@innercontinue@*/ continue;
96 - bingo = 0; /* don't tally hardlink yet. */
97 - /*@innerbreak@*/ break;
101 - fl->totalFileSize += flp->fl_size;
105 ui32 = fl->totalFileSize;