Files
haikuports/sys-apps/file/patches/file-5.40.patchset
2021-05-16 21:53:00 +02:00

137 lines
4.4 KiB
Plaintext

From 9ca3459aa9a4d2fa59434aed51e9bc84de0a3db7 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Thu, 12 May 2016 19:46:43 +0000
Subject: Haiku patch
diff --git a/configure.ac b/configure.ac
index 02eac8f..131a0da 100644
--- a/configure.ac
+++ b/configure.ac
@@ -152,14 +152,14 @@ else
WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
-Wmissing-declarations -Wredundant-decls -Wnested-externs \
-Wsign-compare -Wreturn-type -Wswitch -Wshadow \
- -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
+ -Wcast-qual -Wwrite-strings -Wformat=2"
fi], [
if test "$GCC" = yes; then
AC_MSG_RESULT(yes)
WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
-Wmissing-declarations -Wredundant-decls -Wnested-externs \
-Wsign-compare -Wreturn-type -Wswitch -Wshadow \
- -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
+ -Wcast-qual -Wwrite-strings -Wformat=2"
else
WARNINGS=
AC_MSG_RESULT(no)
diff --git a/src/der.c b/src/der.c
index 4bee9f1..c202ca4 100644
--- a/src/der.c
+++ b/src/der.c
@@ -236,6 +236,7 @@ static int
der_data(char *buf, size_t blen, uint32_t tag, const void *q, uint32_t len)
{
const uint8_t *d = CAST(const uint8_t *, q);
+ uint32_t i;
switch (tag) {
case DER_TAG_PRINTABLE_STRING:
case DER_TAG_UTF8_STRING:
@@ -251,7 +252,7 @@ der_data(char *buf, size_t blen, uint32_t tag, const void *q, uint32_t len)
break;
}
- for (uint32_t i = 0; i < len; i++) {
+ for (i = 0; i < len; i++) {
uint32_t z = i << 1;
if (z < blen - 2)
snprintf(buf + z, blen - z, "%.2x", d[i]);
@@ -264,6 +265,7 @@ der_offs(struct magic_set *ms, struct magic *m, size_t nbytes)
{
const uint8_t *b = RCAST(const uint8_t *, ms->search.s);
size_t offs = 0, len = ms->search.s_len ? ms->search.s_len : nbytes;
+ uint32_t tlen;
if (gettag(b, &offs, len) == DER_BAD) {
DPRINTF(("%s: bad tag 1\n", __func__));
@@ -272,7 +274,7 @@ der_offs(struct magic_set *ms, struct magic *m, size_t nbytes)
DPRINTF(("%s1: %d %" SIZE_T_FORMAT "u %u\n", __func__, ms->offset,
offs, m->offset));
- uint32_t tlen = getlength(b, &offs, len);
+ tlen = getlength(b, &offs, len);
if (tlen == DER_BAD) {
DPRINTF(("%s: bad tag 2\n", __func__));
return -1;
@@ -305,6 +307,7 @@ der_cmp(struct magic_set *ms, struct magic *m)
size_t offs = 0, len = ms->search.s_len;
uint32_t tag, tlen;
char buf[128];
+ size_t slen;
DPRINTF(("%s: compare %zu bytes\n", __func__, len));
@@ -327,7 +330,7 @@ der_cmp(struct magic_set *ms, struct magic *m)
if ((ms->flags & MAGIC_DEBUG) != 0)
fprintf(stderr, "%s: tag %p got=%s exp=%s\n", __func__, b,
buf, s);
- size_t slen = strlen(buf);
+ slen = strlen(buf);
if (strncmp(buf, s, slen) != 0)
return 0;
diff --git a/src/funcs.c b/src/funcs.c
index b926625..5a9462a 100644
--- a/src/funcs.c
+++ b/src/funcs.c
@@ -90,7 +90,8 @@ file_checkfield(char *msg, size_t mlen, const char *what, const char **pp)
protected int
file_checkfmt(char *msg, size_t mlen, const char *fmt)
{
- for (const char *p = fmt; *p; p++) {
+ const char *p;
+ for (p = fmt; *p; p++) {
if (*p != '%')
continue;
if (*++p == '%')
diff --git a/src/readelf.c b/src/readelf.c
index 0cd119a..87964d8 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -1017,6 +1017,7 @@ do_auxv_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
const char *tag;
int is_string;
size_t nval;
+ size_t off;
if ((*flags & (FLAGS_IS_CORE|FLAGS_DID_CORE_STYLE)) !=
(FLAGS_IS_CORE|FLAGS_DID_CORE_STYLE))
@@ -1044,7 +1045,7 @@ do_auxv_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
*flags |= FLAGS_DID_AUXV;
nval = 0;
- for (size_t off = 0; off + elsize <= descsz; off += elsize) {
+ for (off = 0; off + elsize <= descsz; off += elsize) {
memcpy(xauxv_addr, &nbuf[doff + off], xauxv_sizeof);
/* Limit processing to 50 vector entries to prevent DoS */
if (nval++ >= 50) {
@@ -1714,6 +1715,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
if (doread) {
len = xph_filesz < sizeof(nbuf) ? xph_filesz
: sizeof(nbuf);
+{
off_t offs = xph_offset;
bufsize = pread(fd, nbuf, len, offs);
if (bufsize == -1) {
@@ -1723,6 +1725,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
return -1;
return 0;
}
+}
} else
len = 0;
--
2.30.0