|
@@ -1,4 +1,4 @@
|
|
-/* Copyright (c) 2015-2019 the Civetweb developers
|
|
|
|
|
|
+/* Copyright (c) 2015-2020 the Civetweb developers
|
|
*
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
@@ -596,7 +596,7 @@ END_TEST
|
|
START_TEST(test_parse_port_string)
|
|
START_TEST(test_parse_port_string)
|
|
{
|
|
{
|
|
/* Adapted from unit_test.c */
|
|
/* Adapted from unit_test.c */
|
|
- /* Copyright (c) 2013-2018 the Civetweb developers */
|
|
|
|
|
|
+ /* Copyright (c) 2013-2020 the Civetweb developers */
|
|
/* Copyright (c) 2004-2013 Sergey Lyubka */
|
|
/* Copyright (c) 2004-2013 Sergey Lyubka */
|
|
struct t_test_parse_port_string {
|
|
struct t_test_parse_port_string {
|
|
const char *port_string;
|
|
const char *port_string;
|
|
@@ -685,6 +685,16 @@ START_TEST(test_parse_port_string)
|
|
ck_assert_int_eq(htons(so.lsa.sin.sin_port), testdata[i].port_num);
|
|
ck_assert_int_eq(htons(so.lsa.sin.sin_port), testdata[i].port_num);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /* special case: localhost can be ipv4 or ipv6 */
|
|
|
|
+ vec.ptr = "localhost:123";
|
|
|
|
+ vec.len = strlen(vec.ptr);
|
|
|
|
+ ret = parse_port_string(&vec, &so, &ip_family);
|
|
|
|
+ ck_assert_int_eq(ret, 1);
|
|
|
|
+ if ((ip_family != 4) && (ip_family != 6)) {
|
|
|
|
+ ck_abort_msg("IP family must be 4 or 6 but is %i", (int)ip_family);
|
|
|
|
+ }
|
|
|
|
+ ck_assert_int_eq((int)htons(so.lsa.sin.sin_port), (int)123);
|
|
}
|
|
}
|
|
END_TEST
|
|
END_TEST
|
|
|
|
|