Mercurial > hg
comparison mcabber/connwrap/connwrap.c @ 984:3225a1ba050d
Fix a potential libconnwrap issue
Based on a fix from the Debian centericq package,
original patch by Julien Lemoine.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sat, 28 Oct 2006 17:38:53 +0200 |
parents | 6be62425dc38 |
children | eb38963e082f |
comparison
equal
deleted
inserted
replaced
983:e4f154f7c316 | 984:3225a1ba050d |
---|---|
148 return 0; | 148 return 0; |
149 } | 149 } |
150 | 150 |
151 static sslsock *addsock(int fd) { | 151 static sslsock *addsock(int fd) { |
152 sslsock *p; | 152 sslsock *p; |
153 socks = (sslsock *) realloc(socks, sizeof(sslsock)*++sockcount); | 153 |
154 if (socks) | |
155 socks = (sslsock *) realloc(socks, sizeof(sslsock)*++sockcount); | |
156 else | |
157 socks = (sslsock *) malloc(sizeof(sslsock)*++sockcount); | |
154 | 158 |
155 p = &socks[sockcount-1]; | 159 p = &socks[sockcount-1]; |
156 | 160 |
157 init (); | 161 init (); |
158 | 162 |
166 static void delsock(int fd) { | 170 static void delsock(int fd) { |
167 int i, nsockcount; | 171 int i, nsockcount; |
168 sslsock *nsocks; | 172 sslsock *nsocks; |
169 | 173 |
170 nsockcount = 0; | 174 nsockcount = 0; |
171 nsocks = (sslsock *) malloc(sizeof(sslsock)*(sockcount-1)); | 175 |
172 | 176 if (sockcount > 1) { |
173 for(i = 0; i < sockcount; i++) { | 177 nsocks = (sslsock *) malloc(sizeof(sslsock)*(sockcount-1)); |
174 if(socks[i].fd != fd) { | 178 |
175 nsocks[nsockcount++] = socks[i]; | 179 for(i = 0; i < sockcount; i++) { |
176 } else { | 180 if(socks[i].fd != fd) { |
177 SSL_free(socks[i].ssl); | 181 nsocks[nsockcount++] = socks[i]; |
178 } | 182 } else { |
179 } | 183 SSL_free(socks[i].ssl); |
180 | 184 } |
181 free(socks); | 185 } |
182 | 186 |
183 SSL_CTX_free(ctx); | 187 } else { |
184 ctx = 0; | 188 if (ctx) |
185 | 189 SSL_CTX_free(ctx); |
190 ctx = 0; | |
191 nsocks = 0; | |
192 } | |
193 | |
194 if (socks) | |
195 free(socks); | |
186 socks = nsocks; | 196 socks = nsocks; |
187 sockcount = nsockcount; | 197 sockcount = nsockcount; |
188 } | 198 } |
189 | 199 |
190 void cw_set_ssl_options(int sslverify, const char *sslcafile, const char *sslcapath, const char *sslciphers, const char *sslpeer) { | 200 void cw_set_ssl_options(int sslverify, const char *sslcafile, const char *sslcapath, const char *sslciphers, const char *sslpeer) { |