projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make pid files backwards compatible and add address of listening socket.
[tinc]
/
src
/
meta.c
diff --git
a/src/meta.c
b/src/meta.c
index
726dcca
..
29dd824
100644
(file)
--- a/
src/meta.c
+++ b/
src/meta.c
@@
-42,10
+42,9
@@
bool send_meta(connection_t *c, const char *buffer, int length) {
/* Add our data to buffer */
if(c->status.encryptout) {
/* Add our data to buffer */
if(c->status.encryptout) {
- char outbuf[length];
size_t outlen = length;
size_t outlen = length;
- if(!cipher_encrypt(&c->outcipher,
outbuf
, length, buffer_prepare(&c->outbuf, length), &outlen, false) || outlen != length) {
+ if(!cipher_encrypt(&c->outcipher,
buffer
, length, buffer_prepare(&c->outbuf, length), &outlen, false) || outlen != length) {
logger(LOG_ERR, "Error while encrypting metadata to %s (%s)",
c->name, c->hostname);
return false;
logger(LOG_ERR, "Error while encrypting metadata to %s (%s)",
c->name, c->hostname);
return false;
@@
-73,7
+72,7
@@
void broadcast_meta(connection_t *from, const char *buffer, int length) {
}
bool receive_meta(connection_t *c) {
}
bool receive_meta(connection_t *c) {
- int inlen
, reqlen
;
+ int inlen;
char inbuf[MAXBUFSIZE];
char *bufp = inbuf, *endp;
char inbuf[MAXBUFSIZE];
char *bufp = inbuf, *endp;
@@
-86,6
+85,13
@@
bool receive_meta(connection_t *c) {
- If not, keep stuff in buffer and exit.
*/
- If not, keep stuff in buffer and exit.
*/
+ buffer_compact(&c->inbuf, MAXBUFSIZE);
+
+ if(sizeof inbuf <= c->inbuf.len) {
+ logger(LOG_ERR, "Input buffer full for %s (%s)", c->name, c->hostname);
+ return false;
+ }
+
inlen = recv(c->socket, inbuf, sizeof inbuf - c->inbuf.len, 0);
if(inlen <= 0) {
inlen = recv(c->socket, inbuf, sizeof inbuf - c->inbuf.len, 0);
if(inlen <= 0) {
@@
-132,6
+138,7
@@
bool receive_meta(connection_t *c) {
char *tcpbuffer = buffer_read(&c->inbuf, c->tcplen);
if(tcpbuffer) {
receive_tcppacket(c, tcpbuffer, c->tcplen);
char *tcpbuffer = buffer_read(&c->inbuf, c->tcplen);
if(tcpbuffer) {
receive_tcppacket(c, tcpbuffer, c->tcplen);
+ c->tcplen = 0;
continue;
} else {
break;
continue;
} else {
break;