From patchwork Tue Jan 22 00:02:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lev Stipakov X-Patchwork-Id: 667 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director8.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id KODbNKT4RlwWUwAAIUCqbw for ; Tue, 22 Jan 2019 06:04:04 -0500 Received: from proxy14.mail.iad3b.rsapps.net ([172.31.255.6]) by director8.mail.ord1d.rsapps.net with LMTP id uGCrMaT4RlyLdAAAfY0hYg ; Tue, 22 Jan 2019 06:04:04 -0500 Received: from smtp39.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy14.mail.iad3b.rsapps.net with LMTP id iIIkK6T4RlwJLAAA+7ETDg ; Tue, 22 Jan 2019 06:04:04 -0500 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp39.gate.iad3b.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dkim=fail (signature verification failed) header.d=gmail.com; dmarc=fail (p=none; dis=none) header.from=gmail.com X-Suspicious-Flag: YES X-Classification-ID: 6debac20-1e35-11e9-8862-5254002be87c-1-1 Received: from [216.105.38.7] ([216.105.38.7:51226] helo=lists.sourceforge.net) by smtp39.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id A8/6B-05903-4A8F64C5; Tue, 22 Jan 2019 06:04:04 -0500 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1gltpe-0003TJ-UQ; Tue, 22 Jan 2019 11:03:02 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1gltpd-0003T3-IV for openvpn-devel@lists.sourceforge.net; Tue, 22 Jan 2019 11:03:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:To: From:Sender:Reply-To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=nrcSqWwMoiyKzL68ALBgjCHIDOsI5N/DbhNf48qJf50=; b=eQnin6/4UmxKzxESfg0n8vcRP9 3CLI3EwTjVHTR3IRb8Gsz9x8ZW4Py9VE2E4O7CXhhuS3hkNorjJBfguFbUnq/jknLNEZU+yreoWTa DFpqVMdrPlyH/TLc2SjyVcYPU+KEWWf5YP6p7b4mk+fxTxvwNeoHNR1CA3SK5TA0+67I=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc :MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=nrcSqWwMoiyKzL68ALBgjCHIDOsI5N/DbhNf48qJf50=; b=T2m1KFjOEbHfQQW2+sZqkDS44c p69O0Fqr06KaoLxErZONMvQCGDpeQnfU/5iVptfm5WXCX6cE92RxRK33nfRa9j5EkPHbYXTxgJhT1 /N1zWRHy0tB5M1k1morujxoFd3JxmGbJHX0IbEH6O0qFRGWMV6buxJUllZHCe3YBU5NI=; Received: from mail-ed1-f66.google.com ([209.85.208.66]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) id 1gltpc-005Ho2-7E for openvpn-devel@lists.sourceforge.net; Tue, 22 Jan 2019 11:03:01 +0000 Received: by mail-ed1-f66.google.com with SMTP id f9so18919420eds.10 for ; Tue, 22 Jan 2019 03:02:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=nrcSqWwMoiyKzL68ALBgjCHIDOsI5N/DbhNf48qJf50=; b=B+bNdgMnZgiPwIoLwa1eHcukl9YDoqbap8NXLxvfu7sK5N3Bw/lk+lzT3fLmOBXYn8 3Jdl87JjZF7crf5EuMp6AZauSN/VVUr8E80aClYeaFz7jP03WAw+lJh2G7tH5Hmse6dj r9u7cLbqn6k2QoeGhn+ctgFoIs9UXuZ5i8Jz5GbUvJ5i4VBqKjqeNukvaml7l5Elfugk ydUFHMlq8RG+9wymXDC+AZn/xyLg9sdeLjKQ8vhIcM+uBJ7cNO+zrwmHFZZIDbIKpDOK jndBgzaqtKVMPLfaXOsgxL5dM2O5cxs+zHLDVI66v4WxpGnrU/Ayr+lmzHctjQoMnGGC wMrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=nrcSqWwMoiyKzL68ALBgjCHIDOsI5N/DbhNf48qJf50=; b=tB3SkRskqNefKwMn0la5FlvDjV5peMiUwRKPZG16t3LG0X8WbSqRTMGCjcruiLIdoh rMXZaYjwgo9Eu7h2HVBaySMTgFxXpdUsOaax3TJ047qrAKy5pu8c6kyJtabpA9Dero5C yhICDzPLp58uEVLUTWNlD0STFLyCFKac+gna6ShF1oiyVzzO9rl9UJiJPdPQUb6h0ema 66w4/QHyZ8vLrmyJQUpIYyEXYw1cGJyl+EpcbE01NY19cS013Ph6QHj3qeFf4bwDOu5S HjTsDhluYWkIVup/nMCy1TfR/gSeQUmUiM8OfaAJpJxVxMO9/+6nbFNCirUXzpN7DE1p QpSQ== X-Gm-Message-State: AJcUukcznXpNAg5BCTYOYssKLjp0GHotJWQs5uadZBRFltwZnLESL3BW KVPasK04O5V1q1W3H34FavK41Q02wXU= X-Google-Smtp-Source: ALg8bN5pTZBAESH1D7acZ42CVdU2PgGqKXOFS5+AzmqG0kBziHcXsq6BlNkYchn+HSYVZrpYr2y45A== X-Received: by 2002:a17:906:7805:: with SMTP id u5-v6mr28107251ejm.213.1548154973301; Tue, 22 Jan 2019 03:02:53 -0800 (PST) Received: from stipakov.fi (stipakov.fi. [128.199.52.117]) by smtp.gmail.com with ESMTPSA id o37sm9513421edc.32.2019.01.22.03.02.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Jan 2019 03:02:52 -0800 (PST) From: Lev Stipakov To: openvpn-devel@lists.sourceforge.net Date: Tue, 22 Jan 2019 13:02:48 +0200 Message-Id: <1548154968-13019-2-git-send-email-lstipakov@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1548154968-13019-1-git-send-email-lstipakov@gmail.com> References: <1548154968-13019-1-git-send-email-lstipakov@gmail.com> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (lstipakov[at]gmail.com) -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.208.66 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.208.66 listed in wl.mailspike.net] X-Headers-End: 1gltpc-005Ho2-7E Subject: [Openvpn-devel] [PATCH 2/2] test_tls_crypt.c: fix global-buffer-overflow found by AddressSanitizer X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Lev Stipakov When writing data to buffer we incorrectly specify source length - sizeof for pointer returns 8, but actual buffer length is 1. Fix by replacing empty global string to local string literal and specifying the correct length. Signed-off-by: Lev Stipakov --- tests/unit_tests/openvpn/test_tls_crypt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/unit_tests/openvpn/test_tls_crypt.c b/tests/unit_tests/openvpn/test_tls_crypt.c index b793a7a..b4ce03d 100644 --- a/tests/unit_tests/openvpn/test_tls_crypt.c +++ b/tests/unit_tests/openvpn/test_tls_crypt.c @@ -49,8 +49,6 @@ #define PARAM1 "param1" #define PARAM2 "param two" -static const char *plaintext_short = ""; - static const char *test_server_key = \ "-----BEGIN OpenVPN tls-crypt-v2 server key-----\n" "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4v\n" @@ -148,7 +146,7 @@ test_tls_crypt_setup(void **state) { ctx->unwrapped = alloc_buf(TESTBUF_SIZE); /* Write test plaintext */ - buf_write(&ctx->source, plaintext_short, sizeof(plaintext_short)); + buf_write(&ctx->source, "1234567890", 10); /* Write dummy opcode and session id */ buf_write(&ctx->ciphertext, "012345678", 1 + 8);