signature.c: change file size fmt %d -> %zu

Some of the preceding code is probably undefined or unspecified behavior,
but there's no easy way to fix it other than rewriting, which I'm not
going to do.  Surprisingly enough, the code just happens to work, due to
a series of mutual cancellations mod 2^32.  As they say in Russian,
the war will write off all.  Likewise, mod 2^32 arithmetic can write off
a multitude of sins (James 5:20).

> static inline rpmRC checkSize(FD_t fd, int siglen, int pad, int datalen)
[...]
>     int delta;
[...]
>     delta = (sizeof(struct rpmlead) + siglen + pad + datalen) - st.st_size;

Here, the expression in parentheses yields a different numeric value
depending on whether datalen is signed or unsigned.  However, when delta
is finally truncated to 32 bits, the result turns out to be the same.

>     switch (delta) {
>     case -32:	/* XXX rpm-4.0 packages */
>     case 32:	/* XXX Legacy headers have a HEADER_IMAGE tag added. */
>     case 0:
This commit is contained in:
Alexey Tourbin 2018-01-31 01:52:43 +03:00
parent 7db1d19fd8
commit 5eb85a7a5e

View File

@ -137,11 +137,11 @@ static inline rpmRC checkSize(FD_t fd, int siglen, int pad, int datalen)
}
rpmMessage((rc == RPMRC_OK ? RPMMESS_DEBUG : RPMMESS_WARNING),
_("Expected size: %12d = lead(%d)+sigs(%d)+pad(%d)+data(%d)\n"),
(int)sizeof(struct rpmlead)+siglen+pad+datalen,
(int)sizeof(struct rpmlead), siglen, pad, datalen);
_("Expected size: %12zu = lead(%zu)+sigs(%d)+pad(%d)+data(%u)\n"),
sizeof(struct rpmlead)+siglen+pad+datalen,
sizeof(struct rpmlead), siglen, pad, (unsigned)datalen);
rpmMessage((rc == RPMRC_OK ? RPMMESS_DEBUG : RPMMESS_WARNING),
_(" Actual size: %12d\n"), (int)st.st_size);
_(" Actual size: %12zu\n"), (size_t)st.st_size);
return rc;
}