This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.26.9000-745-ge2a9fca


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  e2a9fca8101443076235a8dbcfceaa2d96bf4801 (commit)
       via  5c1a69238fcb87ff7f916a5ce7960b2864afb3a1 (commit)
      from  a19c0a1db50ed3fd58715a1d78ea465d82fe9fd5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=e2a9fca8101443076235a8dbcfceaa2d96bf4801

commit e2a9fca8101443076235a8dbcfceaa2d96bf4801
Author: Florian Weimer <fweimer@redhat.com>
Date:   Sat Nov 11 11:33:32 2017 +0100

    resolv: Add tst-ns_name_pton

diff --git a/ChangeLog b/ChangeLog
index 4906f31..5ddb6fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2017-11-11  Florian Weimer  <fweimer@redhat.com>
 
+	* resolv/tst-ns_name_pton.c: New file.
+	* resolv/Makefile (tests): Add tst-ns_name_pton.
+	(tst-ns_name_pton): Link against libresolv.
+
+2017-11-11  Florian Weimer  <fweimer@redhat.com>
+
 	* resolv/tst-res_hnok.c: New file.
 	* resolv/Makefile (tests): Add tst-res_hnok.
 	(tst-res_hnok): Link against libresolv.
diff --git a/resolv/Makefile b/resolv/Makefile
index 0b8dbf2..0323496 100644
--- a/resolv/Makefile
+++ b/resolv/Makefile
@@ -46,6 +46,7 @@ tests += \
   tst-bug18665-tcp \
   tst-ns_name \
   tst-ns_name_compress \
+  tst-ns_name_pton \
   tst-res_hconf_reorder \
   tst-res_hnok \
   tst-res_use_inet6 \
@@ -173,6 +174,7 @@ $(objpfx)tst-resolv-canonname: \
 $(objpfx)tst-ns_name: $(objpfx)libresolv.so
 $(objpfx)tst-ns_name.out: tst-ns_name.data
 $(objpfx)tst-ns_name_compress: $(objpfx)libresolv.so
+$(objpfx)tst-ns_name_pton: $(objpfx)libresolv.so
 $(objpfx)tst-res_hnok: $(objpfx)libresolv.so
 
 
diff --git a/resolv/tst-ns_name_pton.c b/resolv/tst-ns_name_pton.c
new file mode 100644
index 0000000..879d97c
--- /dev/null
+++ b/resolv/tst-ns_name_pton.c
@@ -0,0 +1,203 @@
+/* Tests for ns_name_pton.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <arpa/nameser.h>
+#include <array_length.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <support/check.h>
+#include <support/support.h>
+#include <support/test-driver.h>
+
+/* Bits which indicate which functions are supposed to report
+   success.  */
+enum
+  {
+    hnok = 1,
+    dnok = 2,
+    mailok = 4,
+    ownok = 8,
+    allnomailok = hnok | dnok | ownok,
+    allok = hnok | dnok | mailok | ownok
+  };
+
+/* A string of 60 characters.  */
+#define STRING60 "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
+
+/* A string of 63 characters (maximum label length).  */
+#define STRING63 STRING60 "zzz"
+
+/* A string of 60 bytes (non-ASCII).  */
+#define STRING60OCT \
+  "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" \
+  "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" \
+  "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" \
+  "\377\377\377\377\377\377\377\377\377"
+
+/* A string of 63 bytes (non-ASCII).  */
+#define STRING63OCT STRING60OCT "\377\377\377"
+
+/* A string of 60 bytes (non-ASCII, quoted decimal).  */
+#define STRING60DEC \
+  "\\255\\255\\255\\255\\255\\255\\255\\255\\255\\255" \
+  "\\255\\255\\255\\255\\255\\255\\255\\255\\255\\255" \
+  "\\255\\255\\255\\255\\255\\255\\255\\255\\255\\255" \
+  "\\255\\255\\255\\255\\255\\255\\255\\255\\255\\255" \
+  "\\255\\255\\255\\255\\255\\255\\255\\255\\255\\255" \
+  "\\255\\255\\255\\255\\255\\255\\255\\255\\255\\255"
+
+/* A string of 63 bytes (non-ASCII, quoted decimal).  */
+#define STRING63DEC STRING60DEC "\\255\\255\\255"
+
+/* Combines a test name with the expected results.  */
+struct test_case
+{
+  const char *dn;
+  const char *back; /* Expected test result converted using ns_name_ntop.  */
+  bool fully_qualified; /* True if the domain name has a trailing dot.  */
+};
+
+static const struct test_case tests[] =
+  {
+    { "", ".", false },
+    { ".", ".", true },
+    { "..", NULL, },
+    { "www", "www", false },
+    { "www.", "www", true },
+    { "www\\.", "www\\.", false },
+    { ".www", NULL, },
+    { ".www\\.", NULL, },
+    { "example.com", "example.com", false },
+    { "example.com.", "example.com", true },
+    { ".example.com", NULL, },
+    { ".example.com.", NULL, },
+    { "example\\.com", "example\\.com", false },
+    { "example\\.com.", "example\\.com", true },
+    { "example..", NULL, },
+    { "example..com", NULL, },
+    { "example..com", NULL, },
+    { "\\0", NULL, },
+    { "\\00", NULL, },
+    { "\\000", "\\000", false },
+    { "\\1", NULL, },
+    { "\\01", NULL, },
+    { "\\001", "\\001", false },
+    { "\\1x", NULL, },
+    { "\\01x", NULL, },
+    { "\\001x", "\\001x", false },
+    { "\\256", NULL, },
+    { "\\0641", "\\@1", false },
+    { "\\0011", "\\0011", false },
+    { STRING63, STRING63, false },
+    { STRING63 ".", STRING63, true },
+    { STRING63 "z", NULL, },
+    { STRING63 "\\.", NULL, },
+    { STRING60 "zz\\.", STRING60 "zz\\.", false },
+    { STRING60 "zz\\..", STRING60 "zz\\.", true },
+    { STRING63 "." STRING63 "." STRING63 "." STRING60 "z",
+      STRING63 "." STRING63 "." STRING63 "." STRING60 "z", false },
+    { STRING63 "." STRING63 "." STRING63 "." STRING60 "z.",
+      STRING63 "." STRING63 "." STRING63 "." STRING60 "z", true },
+    { STRING63 "." STRING63 "." STRING63 "." STRING60 "zz", NULL, },
+    { STRING63 "." STRING63 "." STRING63 "." STRING60 "zzz", NULL, },
+    { STRING63OCT "." STRING63OCT "." STRING63OCT "." STRING60OCT "\377",
+      STRING63DEC "." STRING63DEC "." STRING63DEC "." STRING60DEC "\\255",
+      false },
+    { STRING63OCT "." STRING63OCT "." STRING63OCT "." STRING60OCT "\377.",
+      STRING63DEC "." STRING63DEC "." STRING63DEC "." STRING60DEC "\\255",
+      true },
+    { STRING63OCT "." STRING63OCT "." STRING63OCT "." STRING60OCT
+      "\377\377", NULL, },
+    { STRING63OCT "." STRING63OCT "." STRING63OCT "." STRING60OCT
+      "\377\377\377", NULL, },
+  };
+
+static int
+do_test (void)
+{
+  unsigned char *wire = xmalloc (NS_MAXCDNAME);
+  char *text = xmalloc (NS_MAXDNAME);
+  for (const struct test_case *test = tests; test < array_end (tests); ++test)
+    {
+      if (test_verbose)
+        printf ("info: testing domain name [[[%s]]]\n", test->dn);
+      int ret = ns_name_pton (test->dn, wire, NS_MAXCDNAME);
+      if (ret == -1)
+        {
+          if (test->back != NULL)
+            {
+              support_record_failure ();
+              printf ("error: unexpected decoding failure for [[%s]]\n",
+                      test->dn);
+            }
+          /* Otherwise, we have an expected decoding failure.  */
+          continue;
+        }
+
+      if (ret < -1 || ret > 1)
+        {
+          support_record_failure ();
+          printf ("error: invalid return value %d for [[%s]]\n",
+                  ret, test->dn);
+          continue;
+        }
+
+      int ret2 = ns_name_ntop (wire, text, NS_MAXDNAME);
+
+      if (ret2 < 0)
+        {
+          support_record_failure ();
+          printf ("error: failure to convert back [[%s]]\n", test->dn);
+        }
+
+      if (test->back == NULL)
+        {
+          support_record_failure ();
+          printf ("error: unexpected success converting [[%s]]\n", test->dn);
+          if (ret2 >= 1)
+            printf ("error:   result converts back to [[%s]]\n", test->dn);
+          continue;
+        }
+
+      if (strcmp (text, test->back) != 0)
+        {
+          support_record_failure ();
+          printf ("error: back-conversion of [[%s]] did not match\n",
+                  test->dn);
+          printf ("error:   expected: [[%s]]\n", test->back);
+          printf ("error:     actual: [[%s]]\n", text);
+        }
+
+      if (ret != test->fully_qualified)
+        {
+          support_record_failure ();
+          printf ("error: invalid fully-qualified status for [[%s]]\n",
+                  test->dn);
+          printf ("error:   expected: %d\n", (int) test->fully_qualified);
+          printf ("error:     actual: %d\n", ret);
+        }
+    }
+
+  free (text);
+  free (wire);
+  return 0;
+}
+
+#include <support/test-driver.c>

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=5c1a69238fcb87ff7f916a5ce7960b2864afb3a1

commit 5c1a69238fcb87ff7f916a5ce7960b2864afb3a1
Author: Florian Weimer <fweimer@redhat.com>
Date:   Sat Nov 11 11:23:40 2017 +0100

    resolv: Add tst-res_hnok

diff --git a/ChangeLog b/ChangeLog
index 3654876..4906f31 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2017-11-11  Florian Weimer  <fweimer@redhat.com>
 
+	* resolv/tst-res_hnok.c: New file.
+	* resolv/Makefile (tests): Add tst-res_hnok.
+	(tst-res_hnok): Link against libresolv.
+
+2017-11-11  Florian Weimer  <fweimer@redhat.com>
+
 	* resolv/tst-resolv-network.c: Use test framework instead explicit
 	main function.
 
diff --git a/resolv/Makefile b/resolv/Makefile
index 0f1fcc1..0b8dbf2 100644
--- a/resolv/Makefile
+++ b/resolv/Makefile
@@ -47,6 +47,7 @@ tests += \
   tst-ns_name \
   tst-ns_name_compress \
   tst-res_hconf_reorder \
+  tst-res_hnok \
   tst-res_use_inet6 \
   tst-resolv-basic \
   tst-resolv-edns \
@@ -172,6 +173,7 @@ $(objpfx)tst-resolv-canonname: \
 $(objpfx)tst-ns_name: $(objpfx)libresolv.so
 $(objpfx)tst-ns_name.out: tst-ns_name.data
 $(objpfx)tst-ns_name_compress: $(objpfx)libresolv.so
+$(objpfx)tst-res_hnok: $(objpfx)libresolv.so
 
 
 # This test case uses the deprecated RES_USE_INET6 resolver option.
diff --git a/resolv/tst-res_hnok.c b/resolv/tst-res_hnok.c
new file mode 100644
index 0000000..9c92303
--- /dev/null
+++ b/resolv/tst-res_hnok.c
@@ -0,0 +1,153 @@
+/* Tests for res_hnok and related functions.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <array_length.h>
+#include <resolv.h>
+#include <string.h>
+#include <support/check.h>
+#include <support/test-driver.h>
+
+/* Bits which indicate which functions are supposed to report
+   success.  */
+enum
+  {
+    hnok = 1,
+    dnok = 2,
+    mailok = 4,
+    ownok = 8,
+    allnomailok = hnok | dnok | ownok,
+    allok = hnok | dnok | mailok | ownok
+  };
+
+/* A string of 60 characters.  */
+#define STRING60 "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
+
+/* A string of 63 characters (maximum label length).  */
+#define STRING63 STRING60 "zzz"
+
+/* Combines a test name with the expected results.  */
+struct test_case
+{
+  const char *dn;
+  unsigned int result;          /* Combination of the *ok flags.  */
+};
+
+static const struct test_case tests[] =
+  {
+    { "", allok },
+    { ".", allok },
+    { "www", allnomailok },
+    { "example", allnomailok },
+    { "example.com", allok },
+    { "www.example.com", allok },
+    { "www.example.com.", allok },
+    { "*.example.com", dnok | mailok | ownok },
+    { "-v", dnok },
+    { "-v.example.com", mailok | dnok },
+    { "**.example.com", dnok | mailok },
+    { STRING63, allnomailok },
+    { STRING63 ".example.com", allok },
+    { STRING63 "." STRING63 "." STRING63 "." STRING60 "z", allok },
+    { "hostmaster@mail.example.com", dnok | mailok },
+    { "with whitespace", 0 },
+    { "with\twhitespace", 0 },
+    { "with\nwhitespace", 0 },
+    { "with.whitespace ", 0 },
+    { "with.whitespace\t", 0 },
+    { "with.whitespace\n", 0 },
+    { "with\\ whitespace", 0 },
+    { "with\\\twhitespace", 0 },
+    { "with\\\nwhitespace", 0 },
+    { "with.whitespace\\ ", 0 },
+    { "with.whitespace\\\t", 0 },
+    { "with.whitespace\\\n", 0 },
+  };
+
+/* Run test case *TEST with FUNC (named FUNCNAME) and report an error
+   if the result does not match the result flag at BIT.  */
+static void
+one_test (const struct test_case *test, const char *funcname,
+          int (*func) (const char *), unsigned int bit)
+{
+  int expected = (test->result & bit) != 0;
+  int actual = func (test->dn);
+  if (actual != expected)
+    {
+      support_record_failure ();
+      printf ("error: %s (\"%s\"): expected=%d, actual=%d\n",
+              funcname, test->dn, expected, actual);
+    }
+}
+
+/* Run 255 tests using all the bytes from 1 to 255, surround the byte
+   with the strings PREFIX and SUFFIX, and check that FUNC (named
+   FUNCNAME) accepts only those bytes listed in ACCEPTED.  */
+static void
+one_char (const char *prefix, const char *accepted, const char *suffix,
+          const char *funcname, int (*func) (const char *))
+{
+  for (int ch = 1; ch <= 255; ++ch)
+    {
+      char dn[1024];
+      snprintf (dn, sizeof (dn), "%s%c%s", prefix, ch, suffix);
+      int expected = strchr (accepted, ch) != NULL;
+      int actual = func (dn);
+      if (actual != expected)
+        {
+          support_record_failure ();
+          printf ("error: %s (\"%s\"): expected=%d, actual=%d\n",
+                  funcname, dn, expected, actual);
+        }
+    }
+}
+
+static int
+do_test (void)
+{
+  for (const struct test_case *test = tests; test < array_end (tests); ++test)
+    {
+      if (test_verbose)
+        printf ("info: testing domain name [[[%s]]] (0x%x)\n",
+                test->dn, test->result);
+      one_test (test, "res_hnok", res_hnok, hnok);
+      one_test (test, "res_dnok", res_dnok, dnok);
+      one_test (test, "res_mailok", res_mailok, mailok);
+      one_test (test, "res_ownok", res_ownok, ownok);
+    }
+
+  one_char
+    ("", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.",
+     "", "res_hnok", res_hnok);
+  one_char
+    ("middle",
+     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_",
+     "suffix", "res_hnok", res_hnok);
+  one_char
+    ("middle",
+     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_"
+     "!\"#$%&'()*+,/:;<=>?@[\\]^`{|}~",
+     "suffix.example", "res_mailok", res_mailok);
+  one_char
+    ("mailbox.middle",
+     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_",
+     "suffix.example", "res_mailok", res_mailok);
+
+  return 0;
+}
+
+#include <support/test-driver.c>

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                 |   12 +++
 resolv/Makefile           |    4 +
 resolv/tst-ns_name_pton.c |  203 +++++++++++++++++++++++++++++++++++++++++++++
 resolv/tst-res_hnok.c     |  153 ++++++++++++++++++++++++++++++++++
 4 files changed, 372 insertions(+), 0 deletions(-)
 create mode 100644 resolv/tst-ns_name_pton.c
 create mode 100644 resolv/tst-res_hnok.c


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]