diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 1998-08-16 02:42:12 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 1998-08-16 02:42:12 +0000 |
commit | 364a0613877e4712a7614d08e62ec043adfbf94b (patch) | |
tree | 6d958783b2dd21a5d023a0db66ec592659ae63ad /kerberosIV/kadm | |
parent | 7f6450fdf2329ea9c097d81109b3f08742bf8a4d (diff) |
realloc fixes
Diffstat (limited to 'kerberosIV/kadm')
-rw-r--r-- | kerberosIV/kadm/kadm_cli_wrap.c | 41 | ||||
-rw-r--r-- | kerberosIV/kadm/kadm_stream.c | 31 |
2 files changed, 59 insertions, 13 deletions
diff --git a/kerberosIV/kadm/kadm_cli_wrap.c b/kerberosIV/kadm/kadm_cli_wrap.c index d76f50a620e..3246442308f 100644 --- a/kerberosIV/kadm/kadm_cli_wrap.c +++ b/kerberosIV/kadm/kadm_cli_wrap.c @@ -1,5 +1,17 @@ -/* $OpenBSD: kadm_cli_wrap.c,v 1.5 1997/12/15 17:56:17 art Exp $ */ -/* $KTH: kadm_cli_wrap.c,v 1.22 1997/08/17 07:30:04 assar Exp $ */ +/* $OpenBSD: kadm_cli_wrap.c,v 1.6 1998/08/16 02:42:05 art Exp $ */ +/* $KTH: kadm_cli_wrap.c,v 1.22 1997/08/17 07:30:04 assar Exp $ */ + +/* + * This source code is no longer held under any constraint of USA + * `cryptographic laws' since it was exported legally. The cryptographic + * functions were removed from the code and a "Bones" distribution was + * made. A Commodity Jurisdiction Request #012-94 was filed with the + * USA State Department, who handed it to the Commerce department. The + * code was determined to fall under General License GTDA under ECCN 5D96G, + * and hence exportable. The cryptographic interfaces were re-added by Eric + * Young, and then KTH proceeded to maintain the code in the free world. + * + */ /* Copyright (C) 1989 by the Massachusetts Institute of Technology @@ -239,6 +251,7 @@ kadm_cli_send(u_char *st_dat, int st_siz, u_char **ret_dat, int *ret_siz) * data */ KTEXT_ST authent; /* the authenticator we will build */ u_char *act_st; /* the pointer to the complete packet */ + u_char *temp; u_char *priv_pak; /* private version of the packet */ int priv_len; /* length of private packet */ u_int32_t cksum; /* checksum of the packet */ @@ -293,14 +306,17 @@ kadm_cli_send(u_char *st_dat, int st_siz, u_char **ret_dat, int *ret_siz) RET_N_FREE(retdat + krb_err_base); } - act_st = (u_char *) realloc(act_st, + temp = (u_char *) realloc(act_st, act_len + authent.length + priv_len); - if (act_st == NULL) { + if (temp == NULL) { clear_secrets(); free(priv_pak); + free(act_st); priv_pak = NULL; return KADM_NOMEM; } + act_st = temp; + memcpy((char *)act_st + act_len, authent.dat, authent.length); memcpy((char *)act_st + act_len + authent.length, priv_pak, priv_len); free(priv_pak); @@ -369,6 +385,7 @@ int kadm_change_pw_plain(unsigned char *newkey, char *password, char **pw_msg) { int stsize, retc; /* stream size and return code */ u_char *send_st; /* send stream */ + u_char *temp; u_char *ret_st; int ret_sz; int status; @@ -387,9 +404,12 @@ int kadm_change_pw_plain(unsigned char *newkey, char *password, char **pw_msg) /* change key to stream */ - send_st = realloc(send_st, stsize + 8); - if (send_st == NULL) + temp = realloc(send_st, stsize + 8); + if (temp == NULL) { + free(send_st); return KADM_NOMEM; + } + send_st = temp; memcpy(send_st + stsize + 4, newkey, 4); /* yes, this is backwards */ memcpy(send_st + stsize, newkey + 4, 4); @@ -502,6 +522,7 @@ kadm_mod(Kadm_vals *vals1, Kadm_vals *vals2) u_char *st, *st2; /* st will hold the stream of values */ int st_len, nlen; /* st2 the final stream with opcode */ u_char *ret_st; + u_char *temp; int ret_sz; /* nlen is the length of second vals */ @@ -521,7 +542,13 @@ kadm_mod(Kadm_vals *vals1, Kadm_vals *vals2) st = NULL; nlen = vals_to_stream(vals2, &st); - st2 = (u_char *) realloc((char *) st2, (unsigned)(st_len + nlen)); + temp = (u_char *) realloc((char *) st2, (unsigned)(st_len + nlen)); + if (temp == NULL) { + free(st2); + return KADM_NOMEM; + } + st2 = temp; + memcpy((char *) st2 + st_len, st, nlen); /* append st on */ retc = kadm_cli_send(st2, st_len + nlen, &ret_st, &ret_sz); diff --git a/kerberosIV/kadm/kadm_stream.c b/kerberosIV/kadm/kadm_stream.c index 9f10aa45e1b..791a553a0b4 100644 --- a/kerberosIV/kadm/kadm_stream.c +++ b/kerberosIV/kadm/kadm_stream.c @@ -1,5 +1,17 @@ -/* $OpenBSD: kadm_stream.c,v 1.4 1997/12/12 10:02:47 art Exp $ */ -/* $KTH: kadm_stream.c,v 1.11 1997/05/02 10:28:05 joda Exp $ */ +/* $OpenBSD: kadm_stream.c,v 1.5 1998/08/16 02:42:06 art Exp $ */ +/* $KTH: kadm_stream.c,v 1.11 1997/05/02 10:28:05 joda Exp $ */ + +/* + * This source code is no longer held under any constraint of USA + * `cryptographic laws' since it was exported legally. The cryptographic + * functions were removed from the code and a "Bones" distribution was + * made. A Commodity Jurisdiction Request #012-94 was filed with the + * USA State Department, who handed it to the Commerce department. The + * code was determined to fall under General License GTDA under ECCN 5D96G, + * and hence exportable. The cryptographic interfaces were re-added by Eric + * Young, and then KTH proceeded to maintain the code in the free world. + * + */ /* Copyright (C) 1989 by the Massachusetts Institute of Technology @@ -71,9 +83,15 @@ vts_string(char *dat, u_char **st, int loc) /* base pointer to the stream */ /* offset into the stream for current data */ { - *st = (u_char *) realloc (*st, (unsigned) (loc + strlen(dat) + 1)); - if (*st == NULL) + u_char *temp; + + temp = (u_char *) realloc (*st, (unsigned) (loc + strlen(dat) + 1)); + if (temp == NULL) { + free(*st); return -1; + } + *st = temp; + memcpy(*st + loc, dat, strlen(dat)+1); return strlen(dat)+1; } @@ -86,8 +104,9 @@ vts_short(u_int16_t dat, u_char **st, int loc) /* offset into the stream for current data */ { unsigned char *p; + p = realloc(*st, loc + 2); - if(p == NULL){ + if (p == NULL) { abort(); } p[loc] = (dat >> 8) & 0xff; @@ -103,7 +122,7 @@ vts_char(u_char dat, u_char **st, int loc) /* offset into the stream for current data */ { unsigned char *p = realloc(*st, loc + 1); - if(p == NULL){ + if (p == NULL) { abort(); } p[loc] = dat; |