Skip to contentSkip to conversation

Assertion failed at lzo.c:165

Openvpn-devel Josh Cepek 1 participant 2 messages Jul 19, 2008 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]...

Josh Cepek

author
#1 lore raw

This message was based on a reply I made to the openvpn-users list with some additional details of interest to developers. I apologize for any confusion cross-posting this might cause, but feel the analysis of this from a development perspective didn't really belong in the users list.

The original poster reported this fatal error:
Assertion failed at lzo.c:165

Quoted 1 line · Winfried Truemper

OpenVPN 2.1_rc7 i686-pc-linux-gnu [SSL] [LZO2] [EPOLL] built on Jul 6 2008

For the purpose of identifying the line causing the problem I'm going to assume this is an unpatched version of OpenVPN (or at least one that doesn't change what line 165 is from the vanilla 2.1_rc7 codebase.)

Quoted 2 lines

There is data corruption on the link over which OpenVPN operates. Is that the cause for the failed assertion? It exits from server mode then.

The "Assertion failed at lzo.c:165" message indicates a condition during the compression routine where the packet to compress is larger than the maximum allowable payload size for the connection. Normally this will never occur, but you said that you are operating over a possibly corrupted link. It's possible that the VPN peer is attempting to compress a packet that is malformed and happens to exceed this limit.

Assuming I have read the source correctly, it seems to me that the packet could be dropped (probably with an associated error to the log) rather than using an ASSERT() call. This way malformed data from internal clients behind a VPN peer won't bring down the VPN.

Signature · 1 line
Josh
author
#2 lore raw
Quoted 1 line · Josh Cepek

Assuming I have read the source correctly, it seems to me that the packet could be dropped (probably with an associated error to the log) rather than using an ASSERT() call. This way malformed data from internal clients behind a VPN peer won't bring down the VPN.

I've attached a patch that does this. It compiles & runs fine for me and the logging appears to work as expected (I tested this by reversing the conditional test since I don't have the problem originally reported.)

I'm not completely sure on the correctness of the process to empty the buffer to ignore the packet, but from the other code in this function I believe what I've added will simply cause the bad packet to be ignored.
Feel free to change if necessary.

Signature · 1 line
Josh
home/josh/temp/lzo.c.new renamed from home/josh/src/openvpn/openvpn-2.1_rc7/lzo.c +6 -1
@@ -162,7 +162,12 @@
     {
       ASSERT (buf_init (&work, FRAME_HEADROOM (frame)));
       ASSERT (buf_safe (&work, LZO_EXTRA_BUFFER (PAYLOAD_SIZE (frame))));
-      ASSERT (buf->len <= PAYLOAD_SIZE (frame));
+      if (buf->len > PAYLOAD_SIZE (frame))
+	{
+	  dmsg (D_COMP_ERRORS, "LZO compression failed: buffer exceeds allowable payload length");
+	  buf->len = 0;
+	  return;
+	}
 
       err = LZO_COMPRESS (BPTR (buf), BLEN (buf), BPTR (&work), &zlen, lzowork->wmem);
       if (err != LZO_E_OK)