if (comma) {
/*
- * Disallow empty ALPN at start (",h1") or in the
- * middle ("h1,,h2").
+ * Disallow empty ALPN at start (",h1" or "\,h1") or
+ * in the middle ("h1,,h2" or "h1\,\,h2").
*/
- if (s == source->base || (seen_comma && s == source->base + 1))
- {
+ if ((t - tregion.base - 1) == 0) {
return (DNS_R_SYNTAX);
}
+
+ /*
+ * Consume this ALPN and possible ending comma.
+ */
isc_textregion_consume(source, s - source->base);
+
/*
- * Disallow empty ALPN at end ("h1,").
+ * Disallow empty ALPN at end ("h1," or "h1\,").
*/
if (seen_comma && source->length == 0) {
return (DNS_R_SYNTAX);
}
}
+
*tregion.base = (unsigned char)(t - tregion.base - 1);
isc_buffer_add(target, *tregion.base + 1);
return (ISC_R_SUCCESS);
TEXT_INVALID("2 svc.example.net. alpn=,h1"),
TEXT_INVALID("2 svc.example.net. alpn=h1,"),
TEXT_INVALID("2 svc.example.net. alpn=h1,,h2"),
+ /* empty alpn-id sub fields - RFC 1035 escaped commas */
+ TEXT_INVALID("2 svc.example.net. alpn=\\,abc"),
+ TEXT_INVALID("2 svc.example.net. alpn=abc\\,"),
+ TEXT_INVALID("2 svc.example.net. alpn=a\\,\\,abc"),
/* mandatory */
TEXT_VALID_LOOP(2, "2 svc.example.net. mandatory=alpn "
"alpn=\"h2\""),