From 09dcd5bc8c21edb9b83331242923f0112f8a1b8e Mon Sep 17 00:00:00 2001 From: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> Date: Thu, 12 Feb 2009 15:28:04 -0500 Subject: [PATCH] =?UTF-8?q?Fix=20bug=20in=20reqaccount.c=20-=20Cyrille=20B?= =?UTF-8?q?=C3=A9raud?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sflphone-gtk/src/reqaccount.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/sflphone-gtk/src/reqaccount.c b/sflphone-gtk/src/reqaccount.c index 8bcf344d12..48fccb9831 100644 --- a/sflphone-gtk/src/reqaccount.c +++ b/sflphone-gtk/src/reqaccount.c @@ -1,6 +1,6 @@ /* - * Copyright (C) 2009 Jean Schurger <jean@schurger.org> - * and Savoir-Faire Linux inc. + * Copyright (C) 2009 Savoir-Faire Linux inc. + * Author Jean Schurger <jean.schurger@savoirfairelinux.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -43,25 +43,19 @@ int req(char *host, int port, char *req, char *ret) { int s; struct sockaddr_in servSockAddr; struct hostent *servHostEnt; - long hostAddr; - long status; - int length, i; + long int length=0; + long int status=0; + int i=0; FILE *f; char buf[1024]; bzero(&servSockAddr, sizeof(servSockAddr)); - hostAddr = inet_addr(host); - - if ((long)hostAddr != (long)-1) - bcopy(&hostAddr, &servSockAddr.sin_addr, sizeof(hostAddr)); - else { - servHostEnt = gethostbyname(host); - if (servHostEnt == NULL) { + servHostEnt = gethostbyname(host); + if (servHostEnt == NULL) { strcpy(ret, "gethostbyname"); return -1; - } - bcopy(servHostEnt->h_addr, &servSockAddr.sin_addr, servHostEnt->h_length); } + bcopy((char *)servHostEnt->h_addr, (char *)&servSockAddr.sin_addr, servHostEnt->h_length); servSockAddr.sin_port = htons(port); servSockAddr.sin_family = AF_INET; @@ -70,8 +64,8 @@ int req(char *host, int port, char *req, char *ret) { return -1; } - if(connect(s, (const struct sockaddr *) &servSockAddr, - (socklen_t) sizeof(servSockAddr)) < 0 ) { + if(connect(s, (const struct sockaddr *) &servSockAddr, (socklen_t) sizeof(servSockAddr)) < 0 ) { + perror("foo"); strcpy(ret, "connect"); return -1; } @@ -109,6 +103,7 @@ rest_account get_rest_account(char *host) { char ret[4096]; rest_account ra; bzero(ret, sizeof(ret)); + printf("HOST: %s\n", host); if (req(host, 80, "GET /rest/accountcreator", ret) != -1) { strcpy(ra.user, strtok(ret, "\n")); strcpy(ra.passwd, strtok(NULL, "\n"));\ @@ -117,6 +112,7 @@ rest_account get_rest_account(char *host) { ra.success = 0; strcpy(ra.reason, ret); } + puts(ret); return ra; } -- GitLab