From ca92d83cde6ce6c0c42c60d95c711d5334b76b20 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sun, 2 Oct 2022 18:34:07 -0400 Subject: [PATCH] * src/arscan.c (ar_scan): Avoid sign comparison warnings Pacify 12.2.1 20220819 (Red Hat 12.2.1-2) -Wsign-compare by checking the readbuf() return explicitly for errors then casting from ssize_t. Initial patch provided by Paul Eggert . --- src/arscan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arscan.c b/src/arscan.c index eb806a69..b7180ba2 100644 --- a/src/arscan.c +++ b/src/arscan.c @@ -716,12 +716,12 @@ ar_scan (const char *archive, ar_member_func_t function, const void *arg) const char* err; unsigned int name_len = make_toui (name + 3, &err); - if (err || name_len == 0 || name_len > PATH_MAX) + if (err || name_len == 0 || name_len >= MIN (PATH_MAX, INT_MAX)) goto invalid; name = alloca (name_len + 1); nread = readbuf (desc, name, name_len); - if (nread != name_len) + if (nread < 0 || (unsigned int) nread != name_len) goto invalid; name[name_len] = '\0';