]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
options.c: enforce a minimal fragment size
authorKristof Provost <kp@FreeBSD.org>
Wed, 1 Mar 2023 09:18:51 +0000 (10:18 +0100)
committerGert Doering <gert@greenie.muc.de>
Thu, 2 Mar 2023 17:17:52 +0000 (18:17 +0100)
Very low values for 'fragment' can result in a division by zero in
optimal_fragment_size() (because it rounds max_frag_size down with
FRAG_SIZE_ROUND_MASK).

Enforce a minimal fragment size of 68 bytes, based on RFC 791 ("Every
internet module must be able to forward a datagram of 68 octets without
further fragmentation.")

Signed-off-by: Kristof Provost <kprovost@netgate.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230301091851.82243-1-kprovost@netgate.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26313.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/options.c

index 2e41eea4e2c41abb2080d0971ea142d535b2f7df..45d0e0fa8f37c49d7ac3face828273dc543ed5e4 100644 (file)
@@ -6549,6 +6549,12 @@ add_option(struct options *options,
         VERIFY_PERMISSION(OPT_P_MTU|OPT_P_CONNECTION);
         options->ce.fragment = positive_atoi(p[1]);
 
+        if (options->ce.fragment < 68)
+        {
+            msg(msglevel, "--fragment needs to be at least 68");
+            goto err;
+        }
+
         if (p[2] && streq(p[2], "mtu"))
         {
             options->ce.fragment_encap = true;