Skip to content

Commit 658a23a

Browse files
committed
Remove warnings from inet_pton()/inet_ntop()
1 parent 8e6d7f0 commit 658a23a

File tree

4 files changed

+5
-24
lines changed

4 files changed

+5
-24
lines changed

NEWS

+1
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ PHP NEWS
190190
. Fixed bug #74719 (fopen() should accept NULL as context). (Alexander Holman)
191191
. Fixed bug #69948 (path/domain are not sanitized in setcookie). (cmb)
192192
. Fixed bug #75996 (incorrect url in header for mt_rand). (tatarbj)
193+
. Remove superfluous warnings from inet_ntop()/inet_pton(). (daverandom)
193194

194195
- Testing:
195196
. Implemented request #62055 (Make run-tests.php support --CGI-- sections).

ext/standard/basic_functions.c

-4
Original file line numberDiff line numberDiff line change
@@ -3944,12 +3944,10 @@ PHP_NAMED_FUNCTION(zif_inet_ntop)
39443944
} else
39453945
#endif
39463946
if (address_len != 4) {
3947-
php_error_docref(NULL, E_WARNING, "Invalid in_addr value");
39483947
RETURN_FALSE;
39493948
}
39503949

39513950
if (!inet_ntop(af, address, buffer, sizeof(buffer))) {
3952-
php_error_docref(NULL, E_WARNING, "An unknown error occurred");
39533951
RETURN_FALSE;
39543952
}
39553953

@@ -3980,14 +3978,12 @@ PHP_NAMED_FUNCTION(php_inet_pton)
39803978
} else
39813979
#endif
39823980
if (!strchr(address, '.')) {
3983-
php_error_docref(NULL, E_WARNING, "Unrecognized address %s", address);
39843981
RETURN_FALSE;
39853982
}
39863983

39873984
ret = inet_pton(af, address, buffer);
39883985

39893986
if (ret <= 0) {
3990-
php_error_docref(NULL, E_WARNING, "Unrecognized address %s", address);
39913987
RETURN_FALSE;
39923988
}
39933989

ext/standard/tests/network/inet.phpt

+4-16
Original file line numberDiff line numberDiff line change
@@ -43,33 +43,21 @@ string(13) "255.255.255.0"
4343

4444
Warning: inet_ntop() expects exactly 1 parameter, 0 given in %s on line %d
4545
bool(false)
46-
47-
Warning: inet_ntop(): Invalid in_addr value in %s on line %d
4846
bool(false)
49-
50-
Warning: inet_ntop(): Invalid in_addr value in %s on line %d
5147
bool(false)
52-
53-
Warning: inet_ntop(): Invalid in_addr value in %s on line %d
5448
bool(false)
5549

5650
Warning: inet_pton() expects exactly 1 parameter, 0 given in %s on line %d
5751
bool(false)
58-
59-
Warning: inet_pton(): Unrecognized address in %s on line %d
6052
bool(false)
61-
62-
Warning: inet_pton(): Unrecognized address -1 in %s on line %d
6353
bool(false)
64-
65-
Warning: inet_pton(): Unrecognized address abra in %s on line %d
6654
bool(false)
67-
string(%d) "7f000001"
55+
string(8) "7f000001"
6856
string(9) "127.0.0.1"
69-
string(%d) "42a3a174"
57+
string(8) "42a3a174"
7058
string(14) "66.163.161.116"
71-
string(%d) "ffffffff"
59+
string(8) "ffffffff"
7260
string(15) "255.255.255.255"
73-
string(%d) "00000000"
61+
string(8) "00000000"
7462
string(7) "0.0.0.0"
7563
Done

ext/standard/tests/network/inet_ipv6.phpt

-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ string(3) "::2"
3939
string(4) "::35"
4040
string(5) "::255"
4141
string(6) "::1024"
42-
43-
Warning: inet_pton(): Unrecognized address in %s on line %d
44-
45-
Warning: inet_ntop(): Invalid in_addr value in %s on line %d
4642
bool(false)
4743
string(36) "2001:db8:85a3:8d3:1319:8a2e:370:7344"
4844
string(15) "2001:db8:1234::"

0 commit comments

Comments
 (0)