summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-06-06 05:25:18 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-06-06 05:25:18 +0200
commitd03505bc29e138ee31e04e69c31d4097d236cd40 (patch)
tree1f7b49cde3f0f802dede8665986cd2caee5f6c8b
parentd080f6e8dd873385c984b3138471e28fc604f9cb (diff)
downloadserenity-d03505bc29e138ee31e04e69c31d4097d236cd40.zip
LibC: inet_pton() should return 1 on success, 0 or -1 on failure.
-rw-r--r--LibC/arpa/inet.cpp4
-rw-r--r--Userland/tc.cpp2
-rw-r--r--Userland/uc.cpp4
3 files changed, 7 insertions, 3 deletions
diff --git a/LibC/arpa/inet.cpp b/LibC/arpa/inet.cpp
index 790b9eb715..54fa4d62eb 100644
--- a/LibC/arpa/inet.cpp
+++ b/LibC/arpa/inet.cpp
@@ -29,7 +29,7 @@ int inet_pton(int af, const char* src, void* dst)
int count = sscanf(src, "%u.%u.%u.%u", &a, &b, &c, &d);
if (count != 4) {
errno = EINVAL;
- return -1;
+ return 0;
}
union {
struct {
@@ -45,7 +45,7 @@ int inet_pton(int af, const char* src, void* dst)
u.c = c;
u.d = d;
*(uint32_t*)dst = u.l;
- return 0;
+ return 1;
}
in_addr_t inet_addr(const char* str)
diff --git a/Userland/tc.cpp b/Userland/tc.cpp
index b19aa2a98e..408cbab3fb 100644
--- a/Userland/tc.cpp
+++ b/Userland/tc.cpp
@@ -38,7 +38,7 @@ int main(int argc, char** argv)
dst_addr.sin_family = AF_INET;
dst_addr.sin_port = htons(80);
rc = inet_pton(AF_INET, addr_str, &dst_addr.sin_addr);
- if (rc < 0) {
+ if (rc <= 0) {
perror("inet_pton");
return 1;
}
diff --git a/Userland/uc.cpp b/Userland/uc.cpp
index c5aabda29d..4ef617616e 100644
--- a/Userland/uc.cpp
+++ b/Userland/uc.cpp
@@ -33,6 +33,10 @@ int main(int argc, char** argv)
dst_addr.sin_family = AF_INET;
dst_addr.sin_port = htons(8080);
rc = inet_pton(AF_INET, addr_str, &dst_addr.sin_addr);
+ if (rc <= 0) {
+ perror("inet_pton");
+ return 1;
+ }
char buffer[BUFSIZ];
const char* msg = "Test message";