From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id C6935138334 for ; Sun, 17 Nov 2019 15:12:40 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D45E1E08E2; Sun, 17 Nov 2019 15:12:38 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id AC380E08E2 for ; Sun, 17 Nov 2019 15:12:38 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 34F0434CF38 for ; Sun, 17 Nov 2019 15:12:37 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id AC9458D0 for ; Sun, 17 Nov 2019 15:12:35 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1574000531.ff143361fe3b5eb7befefea5ab45440a6b8716db.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: main.h X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: ff143361fe3b5eb7befefea5ab45440a6b8716db X-VCS-Branch: master Date: Sun, 17 Nov 2019 15:12:35 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 54da0132-eaff-433b-895d-319215140a6a X-Archives-Hash: 77866da0a2060fc9da4181a58fe7ee9e commit: ff143361fe3b5eb7befefea5ab45440a6b8716db Author: Fabian Groffen gentoo org> AuthorDate: Sun Nov 17 14:22:11 2019 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Sun Nov 17 14:22:11 2019 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ff143361 main: ensure READ/WRITE_BE_INT32 operate on the expected bytes we want to work on unsigned bytes such that we don't get sudden unintended operations due to negative value handling Signed-off-by: Fabian Groffen gentoo.org> main.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/main.h b/main.h index ad1467b..03c3bd2 100644 --- a/main.h +++ b/main.h @@ -56,13 +56,16 @@ extern const char *argv0; #endif #define READ_BE_INT32(P) \ - (((P)[0] << 24) | ((P)[1] << 16) | ((P)[2] << 8 ) | (P)[3]) + ((((unsigned char *)(P))[0] << 24) | \ + (((unsigned char *)(P))[1] << 16) | \ + (((unsigned char *)(P))[2] << 8 ) | \ + (((unsigned char *)(P))[3])) #define WRITE_BE_INT32(P,I) \ { \ - (P)[0] = (I & 0xff000000) >> 24; \ - (P)[1] = (I & 0x00ff0000) >> 16; \ - (P)[2] = (I & 0x0000ff00) >> 8; \ - (P)[3] = (I & 0x000000ff); \ + ((unsigned char *)(P))[0] = (I & 0xff000000) >> 24; \ + ((unsigned char *)(P))[1] = (I & 0x00ff0000) >> 16; \ + ((unsigned char *)(P))[2] = (I & 0x0000ff00) >> 8; \ + ((unsigned char *)(P))[3] = (I & 0x000000ff); \ } /* Easy enough to glue to older versions */