[master] 7ff12fdc6 vre: Homework for later

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Fri Sep 3 16:58:06 UTC 2021


commit 7ff12fdc69b0d0ac9ee3d287020157e000c437c6
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Fri Sep 3 18:48:01 2021 +0200

    vre: Homework for later

diff --git a/doc/sphinx/whats-new/upgrading-trunk.rst b/doc/sphinx/whats-new/upgrading-trunk.rst
index d748425b6..470271060 100644
--- a/doc/sphinx/whats-new/upgrading-trunk.rst
+++ b/doc/sphinx/whats-new/upgrading-trunk.rst
@@ -287,6 +287,10 @@ Notable breaking changes:
 - ``VRE_export()`` packs a usable ``vre_t`` that can be persisted as a byte
   stream
 
+An exported regular expression takes the form of a byte stream of a given size
+that can be used as-is by the various matching functions. Care should be taken
+to always maintain pointer alignment of an exported ``vre_t``.
+
 The ``VRE_ERROR_NOMATCH`` symbol is now hard-linked like ``VRE_CASELESS``, and
 ``VRE_NOTEMPTY`` is no longer supported. There are no match options left in
 the VRE facade but the ``VRE_match()``, ``VRE_capture()`` and ``VRE_sub()``
diff --git a/lib/libvarnish/vre.c b/lib/libvarnish/vre.c
index f5dcc848e..a1ad3da51 100644
--- a/lib/libvarnish/vre.c
+++ b/lib/libvarnish/vre.c
@@ -135,6 +135,10 @@ pcre2_code *
 VRE_unpack(const vre_t *code)
 {
 
+	/* XXX: The ban code ensures that regex "lumps" are pointer-aligned,
+	 * but coming for example from a VMOD there is no guarantee. Should
+	 * we formally require that code is properly aligned?
+	 */
 	CHECK_OBJ_NOTNULL(code, VRE_MAGIC);
 	if (code->re == VRE_PACKED_RE) {
 		AZ(code->re_ctx);


More information about the varnish-commit mailing list