Prevent possible buffer overflows when using very large (>= 8192 bit) RSA keys.
Thanks to Tonnerre Lombard for noticing!
This commit is contained in:
parent
02746165a2
commit
e810545dc2
4 changed files with 14 additions and 5 deletions
1
THANKS
1
THANKS
|
@ -23,6 +23,7 @@ We would like to thank the following people for their contributions to tinc:
|
||||||
* Paul Littlefield
|
* Paul Littlefield
|
||||||
* Robert van der Meulen
|
* Robert van der Meulen
|
||||||
* Teemu Kiviniemi
|
* Teemu Kiviniemi
|
||||||
|
* Tonnerre Lombard
|
||||||
* Wessel Dankers
|
* Wessel Dankers
|
||||||
* Wouter van Heyst
|
* Wouter van Heyst
|
||||||
|
|
||||||
|
|
|
@ -56,9 +56,12 @@ typedef struct past_request_t {
|
||||||
|
|
||||||
extern bool tunnelserver;
|
extern bool tunnelserver;
|
||||||
|
|
||||||
/* Maximum size of strings in a request */
|
/* Maximum size of strings in a request.
|
||||||
|
* scanf terminates %2048s with a NUL character,
|
||||||
|
* but the NUL character can be written after the 2048th non-NUL character.
|
||||||
|
*/
|
||||||
|
|
||||||
#define MAX_STRING_SIZE 2048
|
#define MAX_STRING_SIZE 2049
|
||||||
#define MAX_STRING "%2048s"
|
#define MAX_STRING "%2048s"
|
||||||
|
|
||||||
#include "edge.h"
|
#include "edge.h"
|
||||||
|
|
|
@ -118,7 +118,7 @@ bool id_h(connection_t *c)
|
||||||
|
|
||||||
bool send_metakey(connection_t *c)
|
bool send_metakey(connection_t *c)
|
||||||
{
|
{
|
||||||
char buffer[MAX_STRING_SIZE];
|
char *buffer;
|
||||||
int len;
|
int len;
|
||||||
bool x;
|
bool x;
|
||||||
|
|
||||||
|
@ -128,6 +128,8 @@ bool send_metakey(connection_t *c)
|
||||||
|
|
||||||
/* Allocate buffers for the meta key */
|
/* Allocate buffers for the meta key */
|
||||||
|
|
||||||
|
buffer = alloca(2 * len + 1);
|
||||||
|
|
||||||
if(!c->outkey)
|
if(!c->outkey)
|
||||||
c->outkey = xmalloc(len);
|
c->outkey = xmalloc(len);
|
||||||
|
|
||||||
|
@ -302,7 +304,7 @@ bool metakey_h(connection_t *c)
|
||||||
|
|
||||||
bool send_challenge(connection_t *c)
|
bool send_challenge(connection_t *c)
|
||||||
{
|
{
|
||||||
char buffer[MAX_STRING_SIZE];
|
char *buffer;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
cp();
|
cp();
|
||||||
|
@ -313,6 +315,8 @@ bool send_challenge(connection_t *c)
|
||||||
|
|
||||||
/* Allocate buffers for the challenge */
|
/* Allocate buffers for the challenge */
|
||||||
|
|
||||||
|
buffer = alloca(2 * len + 1);
|
||||||
|
|
||||||
if(!c->hischallenge)
|
if(!c->hischallenge)
|
||||||
c->hischallenge = xmalloc(len);
|
c->hischallenge = xmalloc(len);
|
||||||
|
|
||||||
|
|
|
@ -142,10 +142,11 @@ bool req_key_h(connection_t *c)
|
||||||
|
|
||||||
bool send_ans_key(connection_t *c, const node_t *from, const node_t *to)
|
bool send_ans_key(connection_t *c, const node_t *from, const node_t *to)
|
||||||
{
|
{
|
||||||
char key[MAX_STRING_SIZE];
|
char *key;
|
||||||
|
|
||||||
cp();
|
cp();
|
||||||
|
|
||||||
|
key = alloca(2 * from->keylength + 1);
|
||||||
bin2hex(from->key, key, from->keylength);
|
bin2hex(from->key, key, from->keylength);
|
||||||
key[from->keylength * 2] = '\0';
|
key[from->keylength * 2] = '\0';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue