Ver código fonte

libdpkg: add non-regression test for version number starting with non-digit

And update the non-regression test for invalid characters to put
the invalid character as the second character and not the first (which
would be caught by the more strict non-digit check).
Raphaël Hertzog 15 anos atrás
pai
commit
fa98524b58
1 arquivos alterados com 5 adições e 2 exclusões
  1. 5 2
      lib/dpkg/test/t-version.c

+ 5 - 2
lib/dpkg/test/t-version.c

@@ -141,10 +141,13 @@ test_version_parse(void)
 	test_fail(parseversion(&a, "a:0-0") == NULL);
 	test_fail(parseversion(&a, "a:0-0") == NULL);
 	test_fail(parseversion(&a, "A:0-0") == NULL);
 	test_fail(parseversion(&a, "A:0-0") == NULL);
 
 
+	/* Test upstream version not starting with a digit */
+	test_fail(parseversion(&a, "0:abc3-0") == NULL);
+
 	/* Test invalid characters in upstream version. */
 	/* Test invalid characters in upstream version. */
-	verstr = m_strdup("0:0-0");
+	verstr = m_strdup("0:0a-0");
 	for (p = "!#@$%&/|\\<>()[]{};,_=*^'"; *p; p++) {
 	for (p = "!#@$%&/|\\<>()[]{};,_=*^'"; *p; p++) {
-		verstr[2] = *p;
+		verstr[3] = *p;
 		test_fail(parseversion(&a, verstr) == NULL);
 		test_fail(parseversion(&a, verstr) == NULL);
 	}
 	}
 	free(verstr);
 	free(verstr);