Date: Thu, 9 Feb 2023 16:16:29 +0100 From: Frank Lichtenheld Message-ID: References: <20230209142248.455120-1-arne@...1227...> <20230209142248.455120-2-arne@...1227...> MIME-Version: 1.0 In-Reply-To: <20230209142248.455120-2-arne@...1227...> Subject: Re: [Openvpn-devel] [PATCH 2/2] Add debug output for sent IV variables in client mode with verb 7 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit Content-Disposition: inline To: Arne Schwabe Cc: openvpn-devel@lists.sourceforge.net On Thu, Feb 09, 2023 at 03:22:48PM +0100, Arne Schwabe wrote: > This helps debugging what information a client is sending without having to > use a debugger or to look at the server log. > > Signed-off-by: Arne Schwabe > --- > src/openvpn/ssl.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c > index 016bdc57f..1138dc4e7 100644 > --- a/src/openvpn/ssl.c > +++ b/src/openvpn/ssl.c > @@ -1970,6 +1970,20 @@ read_string_alloc(struct buffer *buf) > return str; > } > > +static void > +print_client_peer_info(struct buffer *out, struct gc_arena *gc) > +{ > + struct buffer buf = alloc_buf_gc(buf_len(out), gc); > + buf_copy(&buf, out); > + > + char line[256]; > + > + while (buf_parse(&buf, '\n', line, sizeof(line))) > + { > + chomp(line); > + msg(D_PUSH_DEBUG, "sending peer info: %s", line); > + } > +} While this certainly is the minimal change, actually re-parsing the whole buffer after we have written it feels backwards. Wouldn't it be cleaner to actually wrap the buf_printf calls as something like "add_var" and do the logging as the variables are added? That would avoid the need for the additional allocations and parsing. Regards, -- Frank Lichtenheld