diff --git a/changes/bug17404 b/changes/bug17404
new file mode 100644
index 0000000000000000000000000000000000000000..d524f6662d8e07a4f3cc092f8c3da794f44ba925
--- /dev/null
+++ b/changes/bug17404
@@ -0,0 +1,6 @@
+  o Major bugfixes (security, correctness):
+    - Fix a programming error that could cause us to read 4 bytes before
+      the beginning of an openssl string. This could be used to provoke
+      a crash on systems with an unusual malloc implementation, or
+      systems with unsual hardening installed. Fixes bug 17404; bugfix
+      on 0.2.3.6-alpha.
diff --git a/src/common/tortls.c b/src/common/tortls.c
index 97d0ce2d4cab98608e32783e75bda1b4dbdd970f..b597fe2331e42b1a0b47d86f1d3d047f3b6a1a56 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -2521,6 +2521,10 @@ dn_indicates_v3_cert(X509_NAME *name)
   len = ASN1_STRING_to_UTF8(&s, str);
   if (len < 0)
     return 0;
+  if (len < 4) {
+    OPENSSL_free(s);
+    return 0;
+  }
   r = fast_memneq(s + len - 4, ".net", 4);
   OPENSSL_free(s);
   return r;