106 lines
3.0 KiB
Diff
106 lines
3.0 KiB
Diff
From 3096f87f823e1e936139e48d6a3bae9a95557861 Mon Sep 17 00:00:00 2001
|
|
From: Christos Zoulas <christos@zoulas.com>
|
|
Date: Fri, 9 Apr 2021 19:16:19 +0000
|
|
Subject: [PATCH] No point returning 0 twice, also don't return -1 as an error
|
|
where 0 is expected.
|
|
|
|
---
|
|
src/encoding.c | 14 +++++++++++---
|
|
src/readelf.c | 19 ++++++++-----------
|
|
2 files changed, 19 insertions(+), 14 deletions(-)
|
|
|
|
diff --git src/encoding.c src/encoding.c
|
|
index c66703bb..691e3e16 100644
|
|
--- src/encoding.c
|
|
+++ src/encoding.c
|
|
@@ -1,3 +1,5 @@
|
|
+/* $NetBSD: encoding.c,v 1.1.1.13 2021/04/09 18:58:01 christos Exp $ */
|
|
+
|
|
/*
|
|
* Copyright (c) Ian F. Darwin 1986-1995.
|
|
* Software written by Ian F. Darwin and others;
|
|
@@ -35,7 +37,11 @@
|
|
#include "file.h"
|
|
|
|
#ifndef lint
|
|
-FILE_RCSID("@(#)$File: encoding.c,v 1.28 2021/04/04 21:02:19 christos Exp $")
|
|
+#if 0
|
|
+FILE_RCSID("@(#)$File: encoding.c,v 1.29 2021/04/09 19:16:19 christos Exp $")
|
|
+#else
|
|
+__RCSID("$NetBSD: encoding.c,v 1.1.1.13 2021/04/09 18:58:01 christos Exp $");
|
|
+#endif
|
|
#endif /* lint */
|
|
|
|
#include "magic.h"
|
|
@@ -282,7 +288,8 @@ looks_ ## NAME(const unsigned char *buf, size_t nbytes, file_unichar_t *ubuf, \
|
|
} \
|
|
u = 0; \
|
|
for (i = 0; i < __arraycount(dist); i++) { \
|
|
- u+= dist[i]; \
|
|
+ if (dist[i]) \
|
|
+ u++; \
|
|
} \
|
|
if (u < 3) \
|
|
return 0; \
|
|
@@ -386,7 +393,8 @@ file_looks_utf8(const unsigned char *buf, size_t nbytes, file_unichar_t *ubuf,
|
|
} else { /* 11xxxxxx begins UTF-8 */
|
|
int following;
|
|
uint8_t x = first[buf[i]];
|
|
- const struct accept_range *ar = &accept_ranges[x >> 4];
|
|
+ const struct accept_range *ar =
|
|
+ &accept_ranges[(unsigned int)x >> 4];
|
|
if (x == XX)
|
|
return -1;
|
|
|
|
diff --git src/readelf.c src/readelf.c
|
|
index 0cd119a6..633fd2e8 100644
|
|
--- src/readelf.c
|
|
+++ src/readelf.c
|
|
@@ -27,7 +27,7 @@
|
|
#include "file.h"
|
|
|
|
#ifndef lint
|
|
-FILE_RCSID("@(#)$File: readelf.c,v 1.175 2020/12/17 20:43:37 christos Exp $")
|
|
+FILE_RCSID("@(#)$File: readelf.c,v 1.176 2021/04/09 19:16:19 christos Exp $")
|
|
#endif
|
|
|
|
#ifdef BUILTIN_ELF
|
|
@@ -982,9 +982,8 @@ get_string_on_virtaddr(struct magic_set *ms,
|
|
fsize, virtaddr);
|
|
if (offset < 0 ||
|
|
(buflen = pread(fd, buf, CAST(size_t, buflen), offset)) <= 0) {
|
|
- if (file_printf(ms, ", can't read elf string at %jd",
|
|
- (intmax_t)offset) == -1)
|
|
- return -1;
|
|
+ (void)file_printf(ms, ", can't read elf string at %jd",
|
|
+ (intmax_t)offset);
|
|
return 0;
|
|
}
|
|
|
|
@@ -1185,17 +1184,15 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size,
|
|
}
|
|
|
|
if (namesz & 0x80000000) {
|
|
- if (file_printf(ms, ", bad note name size %#lx",
|
|
- CAST(unsigned long, namesz)) == -1)
|
|
- return -1;
|
|
+ (void)file_printf(ms, ", bad note name size %#lx",
|
|
+ CAST(unsigned long, namesz);
|
|
return 0;
|
|
}
|
|
|
|
if (descsz & 0x80000000) {
|
|
- if (file_printf(ms, ", bad note description size %#lx",
|
|
- CAST(unsigned long, descsz)) == -1)
|
|
- return -1;
|
|
- return 0;
|
|
+ (void)file_printf(ms, ", bad note description size %#lx",
|
|
+ CAST(unsigned long, descsz);
|
|
+ return 0;
|
|
}
|
|
|
|
noff = offset;
|
|
--
|
|
2.28.0
|
|
|