From patchwork Mon Mar 14 04:17:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1604894 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=YCY/7+Tr; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KH3Df5KHtz9sGN for ; Mon, 14 Mar 2022 15:18:10 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KH3Df4Hq6z30HY for ; Mon, 14 Mar 2022 15:18:10 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=YCY/7+Tr; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::42d; helo=mail-pf1-x42d.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=YCY/7+Tr; dkim-atps=neutral Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4KH3DQ4Qwfz2yb9 for ; Mon, 14 Mar 2022 15:17:58 +1100 (AEDT) Received: by mail-pf1-x42d.google.com with SMTP id s11so13145128pfu.13 for ; Sun, 13 Mar 2022 21:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3D6heo1U0ptpz8JQCRUjCDPm7PjwXsx1VsuzAomYQ2M=; b=YCY/7+TrP5+kQjffdHkT0onSodxfemAiel/lG2IgX+zN2J6u7bX1EomtapRyMtki2E 5iC5U0CAJ0qLMcl0+4SYM/DHqYtkIy3XsRTuayq0y85bG7hYAal6ldH5uN51QYC5YZTH xIAbO0bfig5jx3IHe4qF5cQE84DBgqLhyn+QjqKxELmUkY5VQadOCywRJi57c4lB1arI MVmZwbdvKWeKGYovLzZqm5CH2u4/uK+UioedqSiYyCGIS5ELflAOEJEWZQhl6CPdKir2 Td40aOgUzwbrVnJB83gls+V54YN3bhcDazdny3+HzEvaYrWuq0+8BwTidmECG+l1BOiK S4nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3D6heo1U0ptpz8JQCRUjCDPm7PjwXsx1VsuzAomYQ2M=; b=iP4r4S77Ak51ttzNZ/y49rTadw71GFqr79I+POhcJJ9OD416bo1roSV9E9ZHH4xhcb v0GfXw7uez29WYTNc85SBA3VbDIYpy/zXoX0mvEkdS+T+dM7DKr6AnWiweXT3+FrZZZb 5bXAE5k5xS67yehLvNa6bGv5fHYFHSBF5S6cYcInQtvejMSFm2cQmBsLiIHHoaD5Sili RcSsK/uDADigVn3akd0jko/4Fk4qmPyWuSf6XqPbB+Kg8z/UC+YPeCvR7d6MjfzbfNtj x1qH6vcfxk6cv5atQamq4LAFWu5EBamFoCNZ1bGILDC0ayJuPQhPhfgOvJPXnYU+u/yY t30A== X-Gm-Message-State: AOAM531gGw9CW4aa/2HR8EzXyN9IwXAjuqrsDMafrIDp6JlUquPBtKKt fmFqyfDwggYl3XfIbL9hoTIh3MIrAVY= X-Google-Smtp-Source: ABdhPJy8qbbsvwDGhLRb2uvsE7xqqZnFscDEReEMxzk1MG6LHnmWwqDF0X8+djGBArZZ6RegCRGXCw== X-Received: by 2002:a65:6c16:0:b0:380:f45b:f1b2 with SMTP id y22-20020a656c16000000b00380f45bf1b2mr15821713pgu.65.1647231476458; Sun, 13 Mar 2022 21:17:56 -0700 (PDT) Received: from bobo.ibm.com (110-175-148-108.static.tpgi.com.au. [110.175.148.108]) by smtp.gmail.com with ESMTPSA id d16-20020a056a00245000b004f771b48736sm14283018pfj.194.2022.03.13.21.17.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Mar 2022 21:17:56 -0700 (PDT) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Mon, 14 Mar 2022 14:17:27 +1000 Message-Id: <20220314041735.542867-8-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220314041735.542867-1-npiggin@gmail.com> References: <20220314041735.542867-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 06/14] gdbserver: fix read buffer overflow X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" buffer gets NUL terminated so read must return max of size-1. Signed-off-by: Nicholas Piggin Reviewed-by: Joel Stanley --- src/pdbgproxy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c index 906ed2f..78b1236 100644 --- a/src/pdbgproxy.c +++ b/src/pdbgproxy.c @@ -388,7 +388,7 @@ static int read_from_client(int fd) char buffer[BUFFER_SIZE + 1]; int nbytes; - nbytes = read(fd, buffer, sizeof(buffer)); + nbytes = read(fd, buffer, sizeof(buffer) - 1); if (nbytes < 0) { perror(__FUNCTION__); return -1;