summaryrefslogtreecommitdiff
path: root/libmailutils/sockaddr/fromnode.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2017-11-01 08:49:04 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2017-11-01 08:49:04 +0200
commita5e929972db1342beec4b8f577399f2d8d9a76c2 (patch)
tree1a675c7079e626e8439d08bddb5ba0c5b2c6e65d /libmailutils/sockaddr/fromnode.c
parentdbe7332d2241a00f07a571c0b9328d2e841557e0 (diff)
downloadmailutils-a5e929972db1342beec4b8f577399f2d8d9a76c2.tar.gz
mailutils-a5e929972db1342beec4b8f577399f2d8d9a76c2.tar.bz2
Bugfix
* libmailutils/sockaddr/fromnode.c [!MAILUTILS_IPV6] (mu_sockaddr_from_node): Convert port to network order.
Diffstat (limited to 'libmailutils/sockaddr/fromnode.c')
-rw-r--r--libmailutils/sockaddr/fromnode.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libmailutils/sockaddr/fromnode.c b/libmailutils/sockaddr/fromnode.c
index 8f3bd15f4..1f0b12ced 100644
--- a/libmailutils/sockaddr/fromnode.c
+++ b/libmailutils/sockaddr/fromnode.c
@@ -30,6 +30,7 @@
#include <stdio.h>
#include <errno.h>
#include <string.h>
+#include <limits.h>
#include <mailutils/sockaddr.h>
#include <mailutils/url.h>
#include <mailutils/io.h>
@@ -194,8 +195,10 @@ mu_sockaddr_from_node (struct mu_sockaddr **retval, const char *node,
return MU_ERR_SERVICE;
port = sp->s_port;
}
- else if (n == 0 || (port = n) != n)
- return MU_ERR_PARSE; /* FIXME: need MU_ERR_RANGE? */
+ else if (n == 0 || n > USHRT_MAX)
+ return ERANGE;
+ else
+ port = htons (n);
}
else if (mh->port)
port = htons (mh->port);

Return to:

Send suggestions and report system problems to the System administrator.