Date: Wed, 10 May 2023 14:39:31 +0200 From: Frank Lichtenheld Message-ID: References: <20230510112236.248026-1-frank@...2641...> <20230510112236.248026-3-frank@...2641...> MIME-Version: 1.0 In-Reply-To: Subject: Re: [Openvpn-devel] [PATCH 2/3] Change type of frame.mss_fix to uint16_t List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-Disposition: inline To: Gert Doering Cc: openvpn-devel@lists.sourceforge.net On Wed, May 10, 2023 at 01:57:00PM +0200, Gert Doering wrote: > Hi, > > On Wed, May 10, 2023 at 01:22:35PM +0200, Frank Lichtenheld wrote: > > } > > - mssval = (opt[2]<<8)+opt[3]; > > + mssval = opt[2] << 8; > > + mssval += opt[3]; > > Is this an intentional change, or just a side effect of "something > intermediate"? This fixes a conversion warning: ../../../src/openvpn/mss.c:196:26: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Wconversion] 196 | mssval = (opt[2] << 8) + opt[3]; | ^ So basically the compiler goes up to int and then realises it needs to go back down to uint16_t. By splitting the statement this is avoided. One could also fix that with casts, but that would be much uglier, IMHO. > > > @@ -7260,6 +7260,7 @@ add_option(struct options *options, > > /* value specified, assume encapsulation is not > > * included unless "mtu" follows later */ > > options->ce.mssfix = positive_atoi(p[1]); > > + ASSERT(options->ce.mssfix <= UINT16_MAX); > > options->ce.mssfix_encap = false; > > options->ce.mssfix_default = false; > > This part of the patch is making me unhappy, thus, NAK. We do have > a way to signal option errors, and ASSERT() is not... your code > would make a client ASSERT() if a server pushes "mssfix 70000". Okay, will change. Regards, -- Frank Lichtenheld