summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Linehan <patientulysses@gmail.com>2012-06-14 17:52:25 -0400
committerJason Linehan <patientulysses@gmail.com>2012-06-14 17:52:25 -0400
commitaee901418ebfc6dc53c26c367b29854d7cb6e4c2 (patch)
tree9cf2733e5695a2cc1a086ea5e3b54c30a2946eae
parent045b94f8fadd9d66b038741be78f2ed4b0528272 (diff)
downloadcloth-aee901418ebfc6dc53c26c367b29854d7cb6e4c2.tar.gz
cloth-aee901418ebfc6dc53c26c367b29854d7cb6e4c2.tar.bz2
cloth-aee901418ebfc6dc53c26c367b29854d7cb6e4c2.zip
Fixes for network integer conversion
-rw-r--r--cloth.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/cloth.c b/cloth.c
index 29cb58b..e96fdb9 100644
--- a/cloth.c
+++ b/cloth.c
@@ -171,13 +171,15 @@ void procinfo(pid_t pid, int socket, int hit, struct sockaddr_in *client)
{
char buf[BUFSIZE];
char *ip;
- int port;
+ short port;
int fd;
- ip = inet_ntoa(client->sin_addr);
- port = (int)client->sin_port;
+ /* Convert the client address to a char string */
+ ip = inet_ntoa(client->sin_addr);
+ /* Convert the port number to a short */
+ port = ntohs(client->sin_port);
- sprintf(buf, "%d:%d:%d:%s:%d", pid, socket, hit, ip, port);
+ sprintf(buf, "%d:%d:%d:%s:%hd", pid, socket, hit, ip, port);
/* Write the procinfo to the log file */
if ((fd = open(INFO_PATH, O_CREAT| O_WRONLY | O_APPEND, 0644)) >= 0) {