From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id 1E9EC3854158 for ; Mon, 3 Oct 2022 21:24:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1E9EC3854158 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu Received: by mail-wr1-x432.google.com with SMTP id bk15so18521258wrb.13 for ; Mon, 03 Oct 2022 14:24:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=JfnAArMRLKxMqcf20qDT1gywaKQ71z6E/JJbXbCfiDM=; b=UX6BN3SWDYyWykvj0roWDUstUmvPbpguQDz4iDksqOm8HNh5NLhsMsYlX7wY/0QqfP 7YKYMtQK1Ia+NqtcrEom4urOK3in/GFc2ULypHD+/GUxOjVY3kCHKwgP29by4ERp2g5+ iAC93RxLHLOhU50rhDmqL3s8F2lit1UvcUbs8M0nd77KJQgVkGugJVpvyfaCsXcxzCoS 6Jesk7FVAAB9sv4yqhvQRyhrb/djaBV3vkhW1NMoY3Qr/jnI1FLUp1iPrLdQs+N+PtxZ vwrZC2jrfa/4mUSaPraiHpUe/3pslIVXHNBporOwapBIA37alrjPXyYBqlVeS8caJiUT dQiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=JfnAArMRLKxMqcf20qDT1gywaKQ71z6E/JJbXbCfiDM=; b=6hmNN5RQkiGP+8DtBJQmxOfbVd7CmV4D43TTl5mdQHUHNkvm0BPWQqSaw7yr8jr2FG Yaks5OnT/Td7XaBqPhEcIRxp2oe4tSpt9mp8Mt9rW9F0qQ3+rXVxUGWSL/4wQ35nPOGs DwimDQgZVHanOh4u5hh4Fn9cdFjrlyTEBTD4T/1RyqESAivpbPCj4vRMGdvBElObHjUB fHtiWrKUAsUARCIjxxV5n/I5LUmLjN6xfoUC7IxFl9RIVqhc7QlsSh/kY5EsATnrufvL uh0hM6wWVGeLB/bWTXvGGNpuF/qyMJCiOfk/Xkn/QIB479JdLKQtyLuV65hRiuTAWI2l hDTg== X-Gm-Message-State: ACrzQf2rkV7dkB2rIRkKBAw6/b6RtjT7YAGU9tko9gr542GIvmPssnNi WAgSxbejLIw4UN8j0KtFQe/ZxzxoZpFaB/5m X-Google-Smtp-Source: AMsMyM6mNppuQCv0z3imXmXga7Ggc5olAnhCbqkhGHfZcGIxfdmj9cJcdmLjnLGsrjYeVXPh5LecqA== X-Received: by 2002:a05:6000:2c1:b0:226:e7d0:f098 with SMTP id o1-20020a05600002c100b00226e7d0f098mr14521558wry.578.1664832263668; Mon, 03 Oct 2022 14:24:23 -0700 (PDT) Received: from ubuntu-focal.. ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id e16-20020a05600c2dd000b003a83ca67f73sm12995540wmh.3.2022.10.03.14.24.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 14:24:23 -0700 (PDT) From: Philipp Tomsich To: gcc-patches@gcc.gnu.org Cc: Richard Sandiford , Tamar Christina , Christoph Muellner , Philipp Tomsich Subject: [PATCH] aarch64: fix off-by-one in reading cpuinfo Date: Mon, 3 Oct 2022 23:24:19 +0200 Message-Id: <20221003212419.3337714-1-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Fixes: 341573406b39 Don't subtract one from the result of strnlen() when trying to point to the first character after the current string. This issue would cause individual characters (where the 128 byte buffers are stitched together) to be lost. gcc/ChangeLog: * config/aarch64/driver-aarch64.cc (readline): Fix off-by-one. Signed-off-by: Philipp Tomsich --- gcc/config/aarch64/driver-aarch64.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/config/aarch64/driver-aarch64.cc b/gcc/config/aarch64/driver-aarch64.cc index 52ff537908e..48250e68034 100644 --- a/gcc/config/aarch64/driver-aarch64.cc +++ b/gcc/config/aarch64/driver-aarch64.cc @@ -203,9 +203,9 @@ readline (FILE *f) return std::string (); /* If we're not at the end of the line then override the \0 added by fgets. */ - last = strnlen (buf, size) - 1; + last = strnlen (buf, size); } - while (!feof (f) && buf[last] != '\n'); + while (!feof (f) && (last > 0 && buf[last - 1] != '\n')); std::string result (buf); free (buf); -- 2.34.1