NetBSD Problem Report #56840

From www@netbsd.org  Mon May 16 18:19:26 2022
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id B489A1A921F
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 16 May 2022 18:19:26 +0000 (UTC)
Message-Id: <20220516181925.46D3B1A923A@mollari.NetBSD.org>
Date: Mon, 16 May 2022 18:19:25 +0000 (UTC)
From: andrew.cagney@gmail.com
Reply-To: andrew.cagney@gmail.com
To: gnats-bugs@NetBSD.org
Subject: use ntohl(ntohs(cpi)) when 0-extending ipcomp CPI
X-Send-Pr-Version: www-1.0

>Number:         56840
>Category:       kern
>Synopsis:       use ntohl(ntohs(cpi)) when 0-extending ipcomp CPI
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 16 18:20:00 +0000 2022
>Closed-Date:    Fri May 20 23:23:44 +0000 2022
>Last-Modified:  Fri May 20 23:23:44 +0000 2022
>Originator:     Andrew Cagney
>Release:        trunk
>Organization:
>Environment:
trunk
>Description:
use ntohl(ntohs(cpi)) when 0-extending ipcomp CPI

---
 sys/netipsec/ipsec_input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/netipsec/ipsec_input.c b/sys/netipsec/ipsec_input.c
index a5ce54aec96f..7551ca79e3a7 100644
--- a/sys/netipsec/ipsec_input.c
+++ b/sys/netipsec/ipsec_input.c
@@ -229,7 +229,7 @@ ipsec_common_input(struct mbuf *m, int skip, int protoff, int af, int sproto)
 	} else if (sproto == IPPROTO_IPCOMP) {
 		u_int16_t cpi;
 		m_copydata(m, skip + sizeof(u_int16_t), sizeof(u_int16_t), &cpi);
-		spi = ntohl(htons(cpi));
+		spi = htonl(ntohs(cpi));	/* 0 extend */
 	} else {
 		panic("%s called with bad protocol number: %d\n", __func__,
 		    sproto);
-- 
2.35.3

>How-To-Repeat:

>Fix:

>Release-Note:

>Audit-Trail:
From: Andrew Cagney <andrew.cagney@gmail.com>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/56840: use ntohl(ntohs(cpi)) when 0-extending ipcomp CPI
Date: Thu, 19 May 2022 10:12:02 -0400

 Yes, I know, the subject line is also wrong (but I'm pretty sure the
 patch is correct).

 On Mon, 16 May 2022 at 14:20, <gnats-admin@netbsd.org> wrote:
 >
 > Thank you very much for your problem report.
 > It has the internal identification `kern/56840'.
 > The individual assigned to look at your
 > report is: kern-bug-people.
 >
 > >Category:       kern
 > >Responsible:    kern-bug-people
 > >Synopsis:       use ntohl(ntohs(cpi)) when 0-extending ipcomp CPI
 > >Arrival-Date:   Mon May 16 18:20:00 +0000 2022
 >

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/56840 CVS commit: src/sys/netipsec
Date: Thu, 19 May 2022 15:18:03 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Thu May 19 19:18:03 UTC 2022

 Modified Files:
 	src/sys/netipsec: ipsec_input.c

 Log Message:
 PR/56840: Andrew Cagney: use the proper polarity hton/ntoh macros (no
 functional change).
 Factor out spi retrieving code into a function.


 To generate a diff of this commit:
 cvs rdiff -u -r1.75 -r1.76 src/sys/netipsec/ipsec_input.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Fri, 20 May 2022 23:23:44 +0000
State-Changed-Why:
Christos committed it, thanks


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.