summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc46
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/wl_proto.hh2
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc6
3 files changed, 23 insertions, 31 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc
index 5317f52..ae6d406 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc
+++ b/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc
@@ -43,11 +43,8 @@ int get_field(const char *buffer, char *out)
43int send_network_found (const char *guihost, int guiport, void *structure) 43int send_network_found (const char *guihost, int guiport, void *structure)
44{ 44{
45 wl_network_t *ptr; 45 wl_network_t *ptr;
46 char buffer[2048]; 46 char buffer[2048], temp[5];
47 char temp[128]; 47 int len = 0;
48 int retval=0, len=0;
49
50 memset(temp, 0, sizeof(temp));
51 48
52 ptr = (wl_network_t *)structure; 49 ptr = (wl_network_t *)structure;
53 50
@@ -60,27 +57,26 @@ int send_network_found (const char *guihost, int guiport, void *structure)
60 /* Set Net-type */ 57 /* Set Net-type */
61 memset(temp, 0, sizeof(temp)); 58 memset(temp, 0, sizeof(temp));
62 snprintf(temp, sizeof(temp), "%d", ptr->net_type); 59 snprintf(temp, sizeof(temp), "%d", ptr->net_type);
63 retval = add_field(buffer + len, temp, 1); 60 len += add_field(buffer + len, temp, 1);
64 len += retval;
65 61
66 /* Set channel */ 62 /* Set channel */
67 memset(temp, 0, sizeof(temp)); 63 memset(temp, 0, sizeof(temp));
68 snprintf(temp, sizeof(temp), "%.2d", ptr->channel); 64 snprintf(temp, sizeof(temp), "%.2d", ptr->channel);
69 retval = add_field(buffer + len, temp, 2); 65 len += add_field(buffer + len, temp, 2);
70 len += retval;
71 66
72 /* Set WEP y/n */ 67 /* Set WEP y/n */
73 memset(temp, 0, sizeof(temp)); 68 memset(temp, 0, sizeof(temp));
74 snprintf(temp, sizeof(temp), "%d", ptr->wep); 69 snprintf(temp, sizeof(temp), "%d", ptr->wep);
75 retval = add_field(buffer + len, temp, 1); 70 len += add_field(buffer + len, temp, 1);
76 len += retval;
77 71
78 /* Set Mac */ 72 /* Set Mac */
79 retval = add_field(buffer + len, ptr->mac, 17); 73 len += add_field(buffer + len, ptr->mac, 17);
80 len += retval;
81 74
82 /* Set ssid */ 75 /* Set ssid */
83 retval = add_field(buffer + len, ptr->bssid, ptr->ssid_len); 76 if(len + ptr->ssid_len < sizeof(buffer) - 1)
77 len += add_field(buffer + len, ptr->bssid, ptr->ssid_len);
78 else
79 len += add_field(buffer + len, ptr->bssid, sizeof(buffer) - len - 1);
84 80
85 /* Send prepared buffer to UI */ 81 /* Send prepared buffer to UI */
86#ifdef DEBUG 82#ifdef DEBUG
@@ -94,38 +90,34 @@ int send_network_found (const char *guihost, int guiport, void *structure)
94int get_network_found (void *structure, const char *buffer) 90int get_network_found (void *structure, const char *buffer)
95{ 91{
96 wl_network_t *ptr; 92 wl_network_t *ptr;
97 char temp[512]; 93 char temp[5];
98 int retval=0, len=0; 94 int len = 0;
99 95
100 ptr = (wl_network_t *)structure; 96 ptr = (wl_network_t *)structure;
101 97
102 /* packet type already determined */ 98 /* packet type already determined, skip check */
103 len += 2; 99 len += 2;
104 100
105 /* Get net type */ 101 /* Get net type (accesspoint || ad-hoc || ...) */
106 memset(temp, 0, sizeof(temp)); 102 memset(temp, 0, sizeof(temp));
107 retval = get_field(buffer + len, temp); 103 len += get_field(buffer + len, temp);
108 len += retval;
109 ptr->net_type = atoi(temp); 104 ptr->net_type = atoi(temp);
110 105
111 /* Get channel */ 106 /* Get channel */
112 memset(temp, 0, sizeof(temp)); 107 memset(temp, 0, sizeof(temp));
113 retval = get_field(buffer + len, temp); 108 len += get_field(buffer + len, temp);
114 len += retval;
115 ptr->channel = atoi(temp); 109 ptr->channel = atoi(temp);
116 110
117 /* Set WEP y/n */ 111 /* Set WEP y/n */
118 memset(temp, 0, sizeof(temp)); 112 memset(temp, 0, sizeof(temp));
119 retval = get_field(buffer + len, temp); 113 len += get_field(buffer + len, temp);
120 len += retval;
121 ptr->wep = atoi(temp); 114 ptr->wep = atoi(temp);
122 115
123 /* Set MAC address */ 116 /* Set MAC address */
124 retval = get_field(buffer + len, ptr->mac); 117 len += get_field(buffer + len, ptr->mac);
125 len += retval;
126 118
127 /* Set BSSID */ 119 /* Set BSSID */
128 retval = get_field(buffer + len, ptr->bssid); 120 len += get_field(buffer + len, ptr->bssid);
129 121
130 return 1; 122 return 1;
131} 123}
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.hh b/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.hh
index f755589..a196091 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.hh
+++ b/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.hh
@@ -22,7 +22,7 @@ typedef struct {
22 int channel; /* Channel */ 22 int channel; /* Channel */
23 int wep; /* 1 = WEP enabled ; 0 = disabled */ 23 int wep; /* 1 = WEP enabled ; 0 = disabled */
24 char mac[64]; /* MAC address of Accesspoint */ 24 char mac[64]; /* MAC address of Accesspoint */
25 char bssid[128]; /* BSSID of Accesspoint */ 25 char bssid[128]; /* BSSID of Net */
26} wl_network_t; 26} wl_network_t;
27 27
28#endif /* WLPROTO_HH */ 28#endif /* WLPROTO_HH */
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc
index 4942fba..db6b7b8 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc
+++ b/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc
@@ -13,7 +13,7 @@ int wl_setupsock(const char *host, int port)
13 struct sockaddr_in saddr; 13 struct sockaddr_in saddr;
14 int sock; 14 int sock;
15 15
16 if((sock=socket(AF_INET, SOCK_DGRAM, 0)) < 0) 16 if((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
17 { 17 {
18 wl_logerr("Cannot set up socket: %s", strerror(errno)); 18 wl_logerr("Cannot set up socket: %s", strerror(errno));
19 return -1; 19 return -1;
@@ -53,7 +53,7 @@ int wl_send(const char *host, int port, const char *string, ...)
53 saddr.sin_addr.s_addr = inet_addr(host); 53 saddr.sin_addr.s_addr = inet_addr(host);
54 54
55 /* Setup socket */ 55 /* Setup socket */
56 if((sock=socket(AF_INET, SOCK_DGRAM, 0)) < 0) 56 if((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
57 { 57 {
58 wl_logerr("Cannot set up socket: %s", strerror(errno)); 58 wl_logerr("Cannot set up socket: %s", strerror(errno));
59 return 0; 59 return 0;
@@ -76,7 +76,7 @@ int wl_send(const char *host, int port, const char *string, ...)
76int wl_recv(int *sock, char *out, int maxlen) 76int wl_recv(int *sock, char *out, int maxlen)
77{ 77{
78 struct sockaddr_in *cliaddr; 78 struct sockaddr_in *cliaddr;
79 socklen_t len=sizeof(struct sockaddr); 79 socklen_t len = sizeof(struct sockaddr);
80 char retval[3]; 80 char retval[3];
81 81
82 memset(out, 0, maxlen); 82 memset(out, 0, maxlen);