Always initialise PRNG.
Sanity check length of random_vector.
This commit is contained in:
parent
401271b5bb
commit
1c08f2bf3b
3 changed files with 17 additions and 12 deletions
4
Changes
4
Changes
|
|
@ -1,4 +1,4 @@
|
||||||
* Sun Jun 12 2005 Brendan O'Dea <bod@optusnet.com.au> 2.1.1
|
* Tue Jun 14 2005 Brendan O'Dea <bod@optusnet.com.au> 2.1.1
|
||||||
- Add missing newline to backtrace macro.
|
- Add missing newline to backtrace macro.
|
||||||
- Don't send CDN for each session when shutting down tunnels (this is
|
- Don't send CDN for each session when shutting down tunnels (this is
|
||||||
implicit).
|
implicit).
|
||||||
|
|
@ -6,6 +6,8 @@
|
||||||
still_busy(). Reject new tunnels/sessions while in the process of
|
still_busy(). Reject new tunnels/sessions while in the process of
|
||||||
shutting down.
|
shutting down.
|
||||||
- Clarify usage of shutdown signals in documentation.
|
- Clarify usage of shutdown signals in documentation.
|
||||||
|
- Always initialise PRNG.
|
||||||
|
- Sanity check length of random_vector.
|
||||||
|
|
||||||
* Sun Jun 5 2005 Brendan O'Dea <bod@optusnet.com.au> 2.1.0
|
* Sun Jun 5 2005 Brendan O'Dea <bod@optusnet.com.au> 2.1.0
|
||||||
- Add IPv6 support from Jonathan McDowell.
|
- Add IPv6 support from Jonathan McDowell.
|
||||||
|
|
|
||||||
23
l2tpns.c
23
l2tpns.c
|
|
@ -4,7 +4,7 @@
|
||||||
// Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced
|
// Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced
|
||||||
// vim: sw=8 ts=8
|
// vim: sw=8 ts=8
|
||||||
|
|
||||||
char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.109 2005-06-12 06:10:29 bodea Exp $";
|
char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.110 2005-06-14 03:36:23 bodea Exp $";
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
@ -326,7 +326,8 @@ static void initrandom(char *source)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// close previous source, if any
|
// close previous source, if any
|
||||||
if (rand_fd >= 0) close(rand_fd);
|
if (rand_fd >= 0)
|
||||||
|
close(rand_fd);
|
||||||
|
|
||||||
rand_fd = -1;
|
rand_fd = -1;
|
||||||
|
|
||||||
|
|
@ -343,13 +344,6 @@ static void initrandom(char *source)
|
||||||
path, strerror(errno));
|
path, strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// no source: seed prng
|
|
||||||
{
|
|
||||||
unsigned seed = time_now ^ getpid();
|
|
||||||
LOG(4, 0, 0, "Seeding the pseudo random generator: %u\n", seed);
|
|
||||||
srand(seed);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill buffer with random data
|
// fill buffer with random data
|
||||||
|
|
@ -370,7 +364,7 @@ void random_data(uint8_t *buf, int len)
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
|
||||||
// fall back to rand()
|
// fall back to rand()
|
||||||
initrandom(0);
|
initrandom(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
|
|
@ -2274,6 +2268,8 @@ void processudp(uint8_t * buf, int len, struct sockaddr_in *addr)
|
||||||
case 36: // Random Vector
|
case 36: // Random Vector
|
||||||
LOG(4, s, t, " Random Vector received. Enabled AVP Hiding.\n");
|
LOG(4, s, t, " Random Vector received. Enabled AVP Hiding.\n");
|
||||||
memset(session[s].random_vector, 0, sizeof(session[s].random_vector));
|
memset(session[s].random_vector, 0, sizeof(session[s].random_vector));
|
||||||
|
if (n > sizeof(session[s].random_vector))
|
||||||
|
n = sizeof(session[s].random_vector);
|
||||||
memcpy(session[s].random_vector, b, n);
|
memcpy(session[s].random_vector, b, n);
|
||||||
session[s].random_vector_length = n;
|
session[s].random_vector_length = n;
|
||||||
break;
|
break;
|
||||||
|
|
@ -3929,6 +3925,13 @@ int main(int argc, char *argv[])
|
||||||
initrad();
|
initrad();
|
||||||
initippool();
|
initippool();
|
||||||
|
|
||||||
|
// seed prng
|
||||||
|
{
|
||||||
|
unsigned seed = time_now ^ getpid();
|
||||||
|
LOG(4, 0, 0, "Seeding the pseudo random generator: %u\n", seed);
|
||||||
|
srand(seed);
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGHUP, sighup_handler);
|
signal(SIGHUP, sighup_handler);
|
||||||
signal(SIGCHLD, sigchild_handler);
|
signal(SIGCHLD, sigchild_handler);
|
||||||
signal(SIGTERM, shutdown_handler);
|
signal(SIGTERM, shutdown_handler);
|
||||||
|
|
|
||||||
|
|
@ -43,5 +43,5 @@ rm -rf %{buildroot}
|
||||||
%attr(644,root,root) /usr/share/man/man[58]/*
|
%attr(644,root,root) /usr/share/man/man[58]/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Sun Jun 12 2005 Brendan O'Dea <bod@optusnet.com.au> 2.1.1-1
|
* Tue Jun 14 2005 Brendan O'Dea <bod@optusnet.com.au> 2.1.1-1
|
||||||
- 2.1.1 release, see /usr/share/doc/l2tpns-2.1.1/Changes
|
- 2.1.1 release, see /usr/share/doc/l2tpns-2.1.1/Changes
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue