[master] 0062e8cef fix rot13 vdp VDP_END handling and make it produce more vdp calls

Nils Goroll nils.goroll at uplex.de
Thu Oct 8 09:34:06 UTC 2020


commit 0062e8cef7768cd89bf5dfe4b13183ab6a9be11c
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Wed Oct 7 13:58:15 2020 +0200

    fix rot13 vdp VDP_END handling and make it produce more vdp calls
    
    de6288cbe4ac102ebd3ca66cddb64bc12069ee49 was incorrect in that it could
    generate multiple VDP_ENDs, which did not show up during testing because
    of the buffer being large enough to fit any testcase.
    
    Make sure such issues pop up with rot13 testing by using a deliberately
    minuscule buffer.
    
    (and, yeah, we could take it from workspace, but the point is to
     demonstrate and test VDPs...)

diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index 13f602b16..e301c6291 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -97,7 +97,8 @@ static const struct vfp xyzzy_rot13 = {
 
 /**********************************************************************/
 
-#define ROT13_BUFSZ (1 << 13)
+// deliberately fragmenting the stream to make testing more interesting
+#define ROT13_BUFSZ 8
 
 static int v_matchproto_(vdp_init_f)
 xyzzy_rot13_init(struct req *req, void **priv)
@@ -136,8 +137,8 @@ xyzzy_rot13_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
 			q[i] = (((pp[j] - 'a') + 13) % 26) + 'a';
 		else
 			q[i] = pp[j];
-		if (i == ROT13_BUFSZ - 1) {
-			retval = VDP_bytes(vdx, act, q, ROT13_BUFSZ);
+		if (i == ROT13_BUFSZ - 1 && j < len - 1) {
+			retval = VDP_bytes(vdx, VDP_FLUSH, q, ROT13_BUFSZ);
 			if (retval != 0)
 				return (retval);
 			i = -1;


More information about the varnish-commit mailing list