summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sbin/ipsec/photurisd/config.c27
-rw-r--r--sbin/ipsec/photurisd/server.c39
2 files changed, 46 insertions, 20 deletions
diff --git a/sbin/ipsec/photurisd/config.c b/sbin/ipsec/photurisd/config.c
index 59ebac2f89b..0594770abfa 100644
--- a/sbin/ipsec/photurisd/config.c
+++ b/sbin/ipsec/photurisd/config.c
@@ -33,7 +33,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: config.c,v 1.10 1998/06/30 16:58:34 provos Exp $";
+static char rcsid[] = "$Id: config.c,v 1.11 1998/08/17 22:12:44 provos Exp $";
#endif
#define _CONFIG_C_
@@ -202,6 +202,7 @@ init_attributes(void)
int i, def_flag = 0;
char attrib[257];
struct cfgx *cfgattrib = NULL;
+ u_int8_t *newbuf;
#ifdef DEBUG
printf("[Setting up attributes]\n");
@@ -299,11 +300,15 @@ init_attributes(void)
attrib[1] = 0;
/* Copy attributes in object */
- ob->attributes = realloc(ob->attributes,
- ob->attribsize + attrib[1] +2);
- if (ob->attributes == NULL)
+ newbuf = realloc(ob->attributes,
+ ob->attribsize + attrib[1] +2);
+ if (newbuf == NULL) {
+ if (ob->attributes != NULL)
+ free (ob->attributes);
crit_error(1, "realloc() in init_attributes()");
-
+ }
+ ob->attributes = newbuf;
+
bcopy(attrib, ob->attributes + ob->attribsize, attrib[1] + 2);
ob->attribsize += attrib[1] + 2;
@@ -348,6 +353,7 @@ init_schemes(void)
struct moduli_cache *tmp;
mpz_t generator, bits;
u_int32_t scheme_bits;
+ u_int8_t *newbuf;
char *p, *p2;
u_int16_t size;
@@ -419,11 +425,14 @@ init_schemes(void)
buffer[2] = buffer[3] = 0;
}
- global_schemes = realloc(global_schemes, global_schemesize
- + size + 2);
- if (global_schemes == NULL)
+ newbuf = realloc(global_schemes, global_schemesize + size + 2);
+ if (newbuf == NULL) {
+ if (global_schemes != NULL)
+ free (global_schemes);
crit_error(1, "out of memory in init_schems()");
-
+ }
+ global_schemes = newbuf;
+
/* DH_G_2_MD5 is a MUST, so we generate it if gen_flag == 0 */
if (*(u_int16_t *)buffer == htons(DH_G_2_MD5))
gen_flag = 1;
diff --git a/sbin/ipsec/photurisd/server.c b/sbin/ipsec/photurisd/server.c
index 76193e462ba..ac0ec192d17 100644
--- a/sbin/ipsec/photurisd/server.c
+++ b/sbin/ipsec/photurisd/server.c
@@ -35,7 +35,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: server.c,v 1.6 1998/06/30 16:58:40 provos Exp $";
+static char rcsid[] = "$Id: server.c,v 1.7 1998/08/17 22:12:42 provos Exp $";
#endif
#define _SERVER_C_
@@ -79,6 +79,7 @@ init_server(void)
struct stat sb;
int sock, d, i, ip, on = 1;
struct ifconf ifconf;
+ void *newbuf;
char buf[1024];
readfds = normfds = NULL;
@@ -154,16 +155,24 @@ init_server(void)
#ifdef IPSEC
/* We also listen on PF_ENCAP for notify messages */
- addresses = (char **) realloc(addresses,
- (i + 2) * sizeof(char *));
- if (addresses == (char **) NULL)
+ newbuf = realloc(addresses, (i + 2) * sizeof(char *));
+ if (newbuf == NULL) {
+ if (addresses != NULL)
+ free (addresses);
crit_error(1, "realloc() in init_server()");
+ }
+ addresses = (char **) newbuf;
addresses[i + 1] = (char *) NULL;
- sockets = (int *) realloc(sockets, (i + 2)* sizeof(int));
- if (sockets == (int *) NULL)
+ newbuf = realloc(sockets, (i + 2)* sizeof(int));
+ if (newbuf == NULL) {
+ if (sockets != NULL)
+ free (sockets);
crit_error(1, "realloc() in init_server()");
+ }
+ sockets = (int *) newbuf;
+
sockets[i] = kernel_get_socket();
sockets[i+1] = -1;
@@ -184,19 +193,27 @@ init_server(void)
continue;
}
- addresses = (char **) realloc(addresses,
- (i + 2) * sizeof(char *));
- if (addresses == (char **) NULL)
+ newbuf = realloc(addresses, (i + 2) * sizeof(char *));
+ if (newbuf == NULL) {
+ if (addresses != NULL)
+ free (addresses);
crit_error(1, "realloc() in init_server()");
+ }
+ addresses = (char **) newbuf;
addresses[i] = strdup(inet_ntoa(sin2->sin_addr));
if (addresses[i] == (char *) NULL)
crit_error(1, "strdup() in init_server()");
addresses[i + 1] = (char *) NULL;
- sockets = (int *) realloc(sockets, (i + 2)* sizeof(int));
- if (sockets == (int *) NULL)
+ newbuf = realloc(sockets, (i + 2)* sizeof(int));
+ if (newbuf == NULL) {
+ if (sockets != NULL)
+ free (sockets);
crit_error(1, "realloc() in init_server()");
+ }
+ sockets = (int *) newbuf;
+
sockets[i+1] = -1;
if ((sock = socket(PF_INET, SOCK_DGRAM, proto->p_proto)) < 0)