get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2216445/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2216445,
    "url": "http://patchwork.ozlabs.org/api/patches/2216445/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/glibc/patch/20260326125907.3645168-1-carlos@redhat.com/",
    "project": {
        "id": 41,
        "url": "http://patchwork.ozlabs.org/api/projects/41/?format=api",
        "name": "GNU C Library",
        "link_name": "glibc",
        "list_id": "libc-alpha.sourceware.org",
        "list_email": "libc-alpha@sourceware.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20260326125907.3645168-1-carlos@redhat.com>",
    "list_archive_url": null,
    "date": "2026-03-26T12:58:37",
    "name": "[v2] resolv: Check hostname for validity (CVE-2026-4438)",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "7631d333c1d47dd8dcb103f9095c5da9687459b8",
    "submitter": {
        "id": 22438,
        "url": "http://patchwork.ozlabs.org/api/people/22438/?format=api",
        "name": "Carlos O'Donell",
        "email": "carlos@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/glibc/patch/20260326125907.3645168-1-carlos@redhat.com/mbox/",
    "series": [
        {
            "id": 497586,
            "url": "http://patchwork.ozlabs.org/api/series/497586/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/glibc/list/?series=497586",
            "date": "2026-03-26T12:58:37",
            "name": "[v2] resolv: Check hostname for validity (CVE-2026-4438)",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/497586/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2216445/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2216445/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "libc-alpha@sourceware.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@legolas.ozlabs.org",
            "libc-alpha@sourceware.org"
        ],
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=KhaSWVYp;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org;\n receiver=patchwork.ozlabs.org)",
            "sourceware.org;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=KhaSWVYp",
            "sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com",
            "sourceware.org; spf=pass smtp.mailfrom=redhat.com",
            "server2.sourceware.org;\n arc=none smtp.remote-ip=170.10.133.124"
        ],
        "Received": [
            "from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fhP4k055mz1yGD\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 23:59:50 +1100 (AEDT)",
            "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id DEC1C4BA23C2\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 12:59:47 +0000 (GMT)",
            "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by sourceware.org (Postfix) with ESMTP id 4EC334BA2E14\n for <libc-alpha@sourceware.org>; Thu, 26 Mar 2026 12:59:23 +0000 (GMT)",
            "from mail-qt1-f199.google.com (mail-qt1-f199.google.com\n [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-452-Xw2yXc9-NdSpcUKoRlO8_g-1; Thu, 26 Mar 2026 08:59:21 -0400",
            "by mail-qt1-f199.google.com with SMTP id\n d75a77b69052e-50925fed647so29242941cf.3\n for <libc-alpha@sourceware.org>; Thu, 26 Mar 2026 05:59:21 -0700 (PDT)",
            "from codonell-thinkpadp16vgen1.rmtcaon.csb ([198.48.244.52])\n by smtp.gmail.com with ESMTPSA id\n af79cd13be357-8d00e502367sm230467985a.41.2026.03.26.05.59.18\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 26 Mar 2026 05:59:19 -0700 (PDT)"
        ],
        "DKIM-Filter": [
            "OpenDKIM Filter v2.11.0 sourceware.org DEC1C4BA23C2",
            "OpenDKIM Filter v2.11.0 sourceware.org 4EC334BA2E14"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 4EC334BA2E14",
        "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 4EC334BA2E14",
        "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774529963; cv=none;\n b=NqtCwTZKSa+AndNUhuUe9bTSDWNe+sTvN6sWwgQ6SGUPBV52hDo0DW91EcpV64FC7DBFxWjVgPs82QXl2jA9qUG9e0WhVxNcE0Je7S+Xa0fELVr6WKD1jW2wzxvEPflMXY1SVI5ONddLESvQsNRiAY3E3Q4DmYra495uZv1QJHI=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774529963; c=relaxed/simple;\n bh=micK0YmK7hS7xLUA4CMMzycg23ylHE9pzIDWnr9brig=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=cFppUoxUnV9VtCEVb9/3BxKylWzTTE1qJOTFNpQPlw16i81ArcQMUs6ToSGTKQR9vnaiDwYCZACqKybP/oECnlsS3sftIrG0+729Wq3zryuiVuHFDOi/DzqAaW3mw04fui0ziRRV6UE3rj0R27rG3Mn3XnO+lGbtM8FtrQBJHMo=",
        "ARC-Authentication-Results": "i=1; server2.sourceware.org",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1774529963;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding;\n bh=JP18XXkWxSSPvYrtcLOvUFXAPV5+EgL5jpHdVeriKH4=;\n b=KhaSWVYp5NzxOFEE9blTILnZ+x03e3FsiqWxRbU7d09u7+Gt/AqviOG3HzJCXkswCoLkTT\n Olele0ixw+Mgoy2eM8oeH3+WBxngwu8jSCzp9WIgNFXxqjHqKH/I4SVHmOslt1gwC8kZO9\n mAsd9NfWMnjqHuvwHvwECzvFN2aLwis=",
        "X-MC-Unique": "Xw2yXc9-NdSpcUKoRlO8_g-1",
        "X-Mimecast-MFC-AGG-ID": "Xw2yXc9-NdSpcUKoRlO8_g_1774529961",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774529961; x=1775134761;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=JP18XXkWxSSPvYrtcLOvUFXAPV5+EgL5jpHdVeriKH4=;\n b=cIgeRX9G3CSKt4/cr48Pm6kT7/empolP9la5Q3vmGFNwnp3YJdhK/yOCZNVpdpoYLJ\n jSG8Ce77N0XlxLDzKwZOwf0L9q4xqxVVbAsM3DOjdeQEYqFDm/1Bac1JCnhfm7Zk1OPb\n TO5SkSNRGoVGJcmrb8AaBJ1vXdq7yCtwl0zWQ5ScTE2O3gtBcyzn6kH5OgYVBM6UFFq+\n JfKj821R+UiQZt1eEn3tIXm2Ks9LLEk4G02u3cIlDNAncqOTU4OJy3XFCxFqx7RELA7H\n EcVuCljm0pQFfdZlrqS+inSdN432fJqgbvq3yszbs6JJBLgbtnvE1zOFYR5uLQcZ+jr6\n ZNJg==",
        "X-Gm-Message-State": "AOJu0YxRo2ZK8p2W0kQ+a1WkSO/b0YdzfGcbo5Mf9vZAiCUCRY6++eEK\n M9joDYaIdjGldlqtyIejRcZc6lgVSp1dYGRuSYk2+NdpLE4RFjEk/4QceQQvHeHQ/32KpMyGn0j\n UPz2k9TIQgRof71cowOuuXBPGYPl6M2Yy1jAyprs1mRo50nd2FnC5PmrDefRofqYFK3jkYjMhXd\n Mjr7zKiYFQuJNRazmYjIZK/1Fhw23RyP1983WCZF2UE2w=",
        "X-Gm-Gg": "ATEYQzznl3BDz3NAvGPg1ypADjaEQaHjjD3f8FTLBV3E8i1nJs+crSwSMuWKc8DhCs1\n 7idkRM2vEqMoTycohHsBqcvVRxWRfS5GElo+m+8PLraTRfFexFqoRe+bWi+5aXmWHX8By74F1xW\n UrsWiS2XDAcKwGuKldUdpkR1c+gR4EISa+b/n3LdLgEULey0ExYLEMyFo+Z7mBdvPuS5wI6VeAq\n f3yonU+d6+DylaVo/TOm1mrr1OMRaZ+MdjRNEuDC6WgTTx4CDChIPKX8df4UOglzKkoEzv6BGx/\n PQQIUoF2I5zGC4QrygphoAZGXMlUM2celCOpuaPLs+uglvq783brxdxZfLVmEku/bFw1xg3WUgi\n vbhVQzVbC+K9sIIROBVGb1EdotwWVAszS7mC7TUCIU/+h4e661gF83E+Auyxj/8rJzBWTxUy3vR\n G6zZkQ4zMrQ3D54rpN9xpQVCsgFYYJuqQNxdzE8NEFMsBZ98FZVGo=",
        "X-Received": [
            "by 2002:a05:620a:4096:b0:8cd:93b7:ebda with SMTP id\n af79cd13be357-8d00103282bmr1035114285a.49.1774529960555;\n Thu, 26 Mar 2026 05:59:20 -0700 (PDT)",
            "by 2002:a05:620a:4096:b0:8cd:93b7:ebda with SMTP id\n af79cd13be357-8d00103282bmr1035108785a.49.1774529959816;\n Thu, 26 Mar 2026 05:59:19 -0700 (PDT)"
        ],
        "From": "Carlos O'Donell <carlos@redhat.com>",
        "To": "libc-alpha@sourceware.org,\n\tadhemerval.zanella@linaro.org",
        "Cc": "Carlos O'Donell <carlos@redhat.com>",
        "Subject": "[PATCH v2] resolv: Check hostname for validity (CVE-2026-4438)",
        "Date": "Thu, 26 Mar 2026 08:58:37 -0400",
        "Message-ID": "<20260326125907.3645168-1-carlos@redhat.com>",
        "X-Mailer": "git-send-email 2.53.0",
        "MIME-Version": "1.0",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-MFC-PROC-ID": "32V1TKB-3w00CQRNvNHSpktDT5fZBkeTkvgRrlrXAcY_1774529961",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "libc-alpha@sourceware.org",
        "X-Mailman-Version": "2.1.30",
        "Precedence": "list",
        "List-Id": "Libc-alpha mailing list <libc-alpha.sourceware.org>",
        "List-Unsubscribe": "<https://sourceware.org/mailman/options/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe>",
        "List-Archive": "<https://sourceware.org/pipermail/libc-alpha/>",
        "List-Post": "<mailto:libc-alpha@sourceware.org>",
        "List-Help": "<mailto:libc-alpha-request@sourceware.org?subject=help>",
        "List-Subscribe": "<https://sourceware.org/mailman/listinfo/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=subscribe>",
        "Errors-To": "libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org"
    },
    "content": "The processed hostname in getanswer_ptr should be correctly checked to\navoid invalid characters from being allowed, including shell\nmetacharacters. It is a security issue to fail to check the returned\nhostname for validity.\n\nA regression test is added for invalid metacharacters and other cases\nof invalid or valid characters.\n\nNo regressions on x86_64-linux-gnu.\n---\nv1 -> v2\n- Use array_length for test iteration.\n- Sanity check count and enforce limit with array_length.\n\n resolv/Makefile                 |   3 +\n resolv/nss_dns/dns-host.c       |   2 +-\n resolv/tst-resolv-invalid-ptr.c | 255 ++++++++++++++++++++++++++++++++\n 3 files changed, 259 insertions(+), 1 deletion(-)\n create mode 100644 resolv/tst-resolv-invalid-ptr.c",
    "diff": "diff --git a/resolv/Makefile b/resolv/Makefile\nindex 95bad5df27..971608eff5 100644\n--- a/resolv/Makefile\n+++ b/resolv/Makefile\n@@ -117,6 +117,7 @@ tests += \\\n   tst-resolv-dns-section \\\n   tst-resolv-edns \\\n   tst-resolv-invalid-cname \\\n+  tst-resolv-invalid-ptr \\\n   tst-resolv-network \\\n   tst-resolv-noaaaa \\\n   tst-resolv-noaaaa-vc \\\n@@ -312,6 +313,8 @@ $(objpfx)tst-resolv-res_init-thread: $(objpfx)libresolv.so \\\n   $(shared-thread-library)\n $(objpfx)tst-resolv-invalid-cname: $(objpfx)libresolv.so \\\n   $(shared-thread-library)\n+$(objpfx)tst-resolv-invalid-ptr: $(objpfx)libresolv.so \\\n+  $(shared-thread-library)\n $(objpfx)tst-resolv-no-search: $(objpfx)libresolv.so $(shared-thread-library)\n $(objpfx)tst-resolv-noaaaa: $(objpfx)libresolv.so $(shared-thread-library)\n $(objpfx)tst-resolv-noaaaa-vc: $(objpfx)libresolv.so $(shared-thread-library)\ndiff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c\nindex 893137027e..728dae615d 100644\n--- a/resolv/nss_dns/dns-host.c\n+++ b/resolv/nss_dns/dns-host.c\n@@ -866,7 +866,7 @@ getanswer_ptr (unsigned char *packet, size_t packetlen,\n \t  char hname[MAXHOSTNAMELEN + 1];\n \t  if (__ns_name_unpack (c.begin, c.end, rr.rdata,\n \t\t\t\tname_buffer, sizeof (name_buffer)) < 0\n-\t      || !__res_binary_hnok (expected_name)\n+\t      || !__res_binary_hnok (name_buffer)\n \t      || __ns_name_ntop (name_buffer, hname, sizeof (hname)) < 0)\n \t    {\n \t      *h_errnop = NO_RECOVERY;\ndiff --git a/resolv/tst-resolv-invalid-ptr.c b/resolv/tst-resolv-invalid-ptr.c\nnew file mode 100644\nindex 0000000000..0c802ab967\n--- /dev/null\n+++ b/resolv/tst-resolv-invalid-ptr.c\n@@ -0,0 +1,255 @@\n+/* Test handling of invalid T_PTR results (bug 34015).\n+   Copyright (C) 2022-2026 Free Software Foundation, Inc.\n+   This file is part of the GNU C Library.\n+\n+   The GNU C Library is free software; you can redistribute it and/or\n+   modify it under the terms of the GNU Lesser General Public\n+   License as published by the Free Software Foundation; either\n+   version 2.1 of the License, or (at your option) any later version.\n+\n+   The GNU C Library is distributed in the hope that it will be useful,\n+   but WITHOUT ANY WARRANTY; without even the implied warranty of\n+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+   Lesser General Public License for more details.\n+\n+   You should have received a copy of the GNU Lesser General Public\n+   License along with the GNU C Library; if not, see\n+   <https://www.gnu.org/licenses/>.  */\n+\n+#include <array_length.h>\n+#include <errno.h>\n+#include <netdb.h>\n+#include <resolv.h>\n+#include <stdlib.h>\n+#include <string.h>\n+#include <support/check.h>\n+#include <support/format_nss.h>\n+#include <support/resolv_test.h>\n+#include <support/support.h>\n+\n+/* Name of test, the answer, the expected error return, and if we\n+   expect the call to fail.  */\n+struct item {\n+  const char *test;\n+  const char *answer;\n+  int expected;\n+  bool fail;\n+};\n+\n+static const struct item test_items[] =\n+  {\n+    /* Test for invalid characters.  */\n+    { \"Invalid use of \\\"|\\\"\",\n+      \"test.|.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"&\\\"\",\n+      \"test.&.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\";\\\"\",\n+      \"test.;.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"<\\\"\",\n+      \"test.<.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\">\\\"\",\n+      \"test.>.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"(\\\"\",\n+      \"test.(.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\")\\\"\",\n+      \"test.).ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"$\\\"\",\n+      \"test.$.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"`\\\"\",\n+      \"test.`.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"\\\\\\\"\",\n+      \"test.\\\\.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"\\'\\\"\",\n+      \"test.'.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"\\\"\\\"\",\n+      \"test.\\\".ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\" \\\"\",\n+      \"test. .ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"\\\\t\\\"\",\n+      \"test.\\t.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"\\\\n\\\"\",\n+      \"test.\\n.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"\\\\r\\\"\",\n+      \"test.\\r.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"*\\\"\",\n+      \"test.*.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"?\\\"\",\n+      \"test.?.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"[\\\"\",\n+      \"test.[.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"]\\\"\",\n+      \"test.].ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\",\\\"\",\n+      \"test.,.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"~\\\"\",\n+      \"test.~.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\":\\\"\",\n+      \"test.:.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"!\\\"\",\n+      \"test.!.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"@\\\"\",\n+      \"test.@.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"#\\\"\",\n+      \"test.#.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"%\\\"\",\n+      \"test.%%.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of \\\"^\\\"\",\n+      \"test.^.ptr.example\", NO_RECOVERY, true },\n+\n+    /* Test for invalid UTF-8 characters (2-byte, 4-byte, 6-byte).  */\n+    { \"Invalid use of UTF-8 (2-byte, U+00C0-U+00C2)\",\n+      \"ÁÂÃ.test.ptr.example\", NO_RECOVERY, true },\n+    { \"Invalid use of UTF-8 (4-byte, U+0750-U+0752)\",\n+      \"ݐݑݒ.test.ptr.example\", NO_RECOVERY, true },\n+     { \"Invalid use of UTF-8 (6-byte, U+0904-U+0906)\",\n+      \"ऄअआ.test.ptr.example\", NO_RECOVERY, true },\n+\n+    /* Test for \"-\" which may be valid depending on position.  */\n+    { \"Invalid leading \\\"-\\\"\",\n+      \"-test.ptr.example\", NO_RECOVERY, true },\n+    { \"Valid trailing \\\"-\\\"\",\n+      \"test-.ptr.example\", 0, false },\n+    { \"Valid mid-label use of \\\"-\\\"\",\n+      \"te-st.ptr.example\", 0, false },\n+\n+    /* Test for \"_\" which is always valid in any position.  */\n+    { \"Valid leading use of \\\"_\\\"\",\n+      \"_test.ptr.example\", 0, false },\n+    { \"Valid mid-label use of \\\"_\\\"\",\n+      \"te_st.ptr.example\", 0, false },\n+    { \"Valid trailing use of \\\"_\\\"\",\n+      \"test_.ptr.example\", 0, false },\n+\n+    /* Sanity test the broader set [A-Za-z0-9_-] of valid characters.  */\n+    { \"Valid \\\"[A-Z]\\\"\",\n+      \"test.ABCDEFGHIJKLMNOPQRSTUVWXYZ.ptr.example\", 0, false },\n+    { \"Valid \\\"[a-z]\\\"\",\n+      \"test.abcdefghijklmnopqrstuvwxyz.ptr.example\", 0, false },\n+    { \"Valid \\\"[0-9]\\\"\",\n+      \"test.0123456789.ptr.example\", 0, false },\n+    { \"Valid mixed use of \\\"[A-Za-z0-9_-]\\\"\",\n+      \"test.012abcABZ_-.ptr.example\", 0, false },\n+  };\n+\n+static void\n+response (const struct resolv_response_context *ctx,\n+          struct resolv_response_builder *b,\n+          const char *qname, uint16_t qclass, uint16_t qtype)\n+{\n+  TEST_COMPARE (qclass, C_IN);\n+\n+  /* We only test PTR.  */\n+  TEST_COMPARE (qtype, T_PTR);\n+\n+  unsigned int count, count1;\n+  char *tail = NULL;\n+\n+  /* The test implementation can handle up to 255 tests.  */\n+  if (strstr (qname, \"in-addr.arpa\") != NULL\n+      && sscanf (qname, \"%u.%ms\", &count, &tail) == 2)\n+    TEST_COMPARE_STRING (tail, \"0.168.192.in-addr.arpa\");\n+  else if (sscanf (qname, \"%x.%x.%ms\", &count, &count1, &tail) == 3)\n+    {\n+      TEST_COMPARE_STRING (tail, \"\\\n+0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa\");\n+      count |= count1 << 4;\n+    }\n+  else\n+    FAIL_EXIT1 (\"invalid QNAME: %s\\n\", qname);\n+  free (tail);\n+\n+  /* Cross check. Count has a fixed bound (soft limit).  */\n+  TEST_VERIFY (count >= 0 && count <= 255);\n+\n+  /* We have a fixed number of tests (hard limit).  */\n+  TEST_VERIFY_EXIT (count < array_length (test_items));\n+\n+  struct resolv_response_flags flags = {};\n+  resolv_response_init (b, flags);\n+  resolv_response_add_question (b, qname, qclass, qtype);\n+  resolv_response_section (b, ns_s_an);\n+\n+  /* Actual answer record.  */\n+  resolv_response_open_record (b, qname, qclass, qtype, 60);\n+\n+  /* Record the answer.  */\n+  resolv_response_add_name (b, test_items[count].answer);\n+  resolv_response_close_record (b);\n+}\n+\n+/* Perform one check using a reverse lookup.  */\n+static void\n+check_reverse (int af, int count)\n+{\n+  TEST_VERIFY (af == AF_INET || af == AF_INET6);\n+  TEST_VERIFY_EXIT (count < array_length (test_items));\n+\n+  /* Generate an address to query for each test.  */\n+  char addr[sizeof (struct in6_addr)] = { 0 };\n+  socklen_t addrlen;\n+  if (af == AF_INET)\n+    {\n+      addr[0] = (char) 192;\n+      addr[1] = (char) 168;\n+      addr[2] = (char) 0;\n+      addr[3] = (char) count;\n+      addrlen = 4;\n+    }\n+  else\n+    {\n+      addr[0] = 0x20;\n+      addr[1] = 0x01;\n+      addr[2] = 0x0d;\n+      addr[3] = 0xb8;\n+      addr[4] = addr[5] = addr[6] = addr[7] = 0x0;\n+      addr[8] = addr[9] = addr[10] = addr[11] = 0x0;\n+      addr[12] = 0x0;\n+      addr[13] = 0x0;\n+      addr[14] = 0x0;\n+      addr[15] = (char) count;\n+      addrlen = 16;\n+    }\n+\n+  h_errno = 0;\n+  struct hostent *answer = gethostbyaddr (addr, addrlen, af);\n+\n+  /* Verify h_errno is as expected.  */\n+  TEST_COMPARE (h_errno, test_items[count].expected);\n+  if (h_errno != test_items[count].expected)\n+    /* And print more information if it's not.  */\n+    printf (\"INFO: %s\\n\", test_items[count].test);\n+\n+  if (test_items[count].fail)\n+    {\n+      /* We expected a failure so verify answer is NULL.  */\n+      TEST_VERIFY (answer == NULL);\n+      /* If it's not NULL we should print out what we received.  */\n+      if (answer != NULL)\n+        printf (\"error: unexpected success: %s\\n\",\n+\t\tsupport_format_hostent (answer));\n+    }\n+  else\n+    /* We don't expect a failure so answer must be valid.  */\n+    TEST_COMPARE_STRING (answer->h_name, test_items[count].answer);\n+}\n+\n+static int\n+do_test (void)\n+{\n+  struct resolv_test *obj = resolv_test_start\n+    ((struct resolv_redirect_config)\n+     {\n+       .response_callback = response\n+     });\n+\n+  for (int i = 0; i < array_length (test_items); i++)\n+    {\n+      check_reverse (AF_INET, i);\n+      check_reverse (AF_INET6, i);\n+    }\n+  resolv_test_end (obj);\n+\n+  return 0;\n+}\n+\n+#include <support/test-driver.c>\n",
    "prefixes": [
        "v2"
    ]
}