diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 1997-12-12 10:02:48 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 1997-12-12 10:02:48 +0000 |
commit | e9661eae9354189ee0fd73e835fb8243ebc1b6db (patch) | |
tree | 1c5d304e1e3f211a69365a8327c9b1ff466739b3 /kerberosIV/kadm/kadm_supp.c | |
parent | c2e173d16ac5aa279c3b4432abe23c6fb9a948ef (diff) |
Clean up, check pointers, etc.
Diffstat (limited to 'kerberosIV/kadm/kadm_supp.c')
-rw-r--r-- | kerberosIV/kadm/kadm_supp.c | 112 |
1 files changed, 62 insertions, 50 deletions
diff --git a/kerberosIV/kadm/kadm_supp.c b/kerberosIV/kadm/kadm_supp.c index 4a771ff5fca..f3ff2fca573 100644 --- a/kerberosIV/kadm/kadm_supp.c +++ b/kerberosIV/kadm/kadm_supp.c @@ -1,3 +1,4 @@ +/* $OpenBSD: kadm_supp.c,v 1.3 1997/12/12 10:02:46 art Exp $ */ /* $KTH: kadm_supp.c,v 1.8 1997/05/02 10:27:58 joda Exp $ */ /* @@ -44,14 +45,14 @@ prin_vals: void prin_vals(Kadm_vals *vals) { - printf("Info in Database for %s.%s:\n", vals->name, vals->instance); - printf(" Max Life: %d (%s) Exp Date: %s\n", - vals->max_life, - krb_life_to_atime(vals->max_life), - asctime(k_localtime(&vals->exp_date))); - printf(" Attribs: %.2x key: %#lx %#lx\n", - vals->attributes, - (long)vals->key_low, (long)vals->key_high); + printf("Info in Database for %s.%s:\n", vals->name, vals->instance); + printf(" Max Life: %d (%s) Exp Date: %s\n", + vals->max_life, + krb_life_to_atime(vals->max_life), + asctime(k_localtime(&vals->exp_date))); + printf(" Attribs: %.2x key: %#lx %#lx\n", + vals->attributes, + (long)vals->key_low, (long)vals->key_high); } /* kadm_prin_to_vals takes a fields arguments, a Kadm_vals and a Principal, @@ -61,51 +62,62 @@ prin_vals(Kadm_vals *vals) void kadm_prin_to_vals(u_char *fields, Kadm_vals *new, Principal *old) { - memset(new, 0, sizeof(*new)); - if (IS_FIELD(KADM_NAME,fields)) { - strncpy(new->name, old->name, ANAME_SZ); - SET_FIELD(KADM_NAME, new->fields); - } - if (IS_FIELD(KADM_INST,fields)) { - strncpy(new->instance, old->instance, INST_SZ); - SET_FIELD(KADM_INST, new->fields); - } - if (IS_FIELD(KADM_EXPDATE,fields)) { - new->exp_date = old->exp_date; - SET_FIELD(KADM_EXPDATE, new->fields); - } - if (IS_FIELD(KADM_ATTR,fields)) { - new->attributes = old->attributes; - SET_FIELD(KADM_ATTR, new->fields); - } - if (IS_FIELD(KADM_MAXLIFE,fields)) { - new->max_life = old->max_life; - SET_FIELD(KADM_MAXLIFE, new->fields); - } - if (IS_FIELD(KADM_DESKEY,fields)) { - new->key_low = old->key_low; - new->key_high = old->key_high; - SET_FIELD(KADM_DESKEY, new->fields); - } + if (new == NULL) + return; + + memset(new, 0, sizeof(*new)); + if (IS_FIELD(KADM_NAME,fields)) { + strncpy(new->name, old->name, ANAME_SZ - 1); + new->name[ANAME_SZ - 1] = '\0'; + SET_FIELD(KADM_NAME, new->fields); + } + if (IS_FIELD(KADM_INST,fields)) { + strncpy(new->instance, old->instance, INST_SZ - 1); + new->instance[INST_SZ - 1] = '\0'; + SET_FIELD(KADM_INST, new->fields); + } + if (IS_FIELD(KADM_EXPDATE,fields)) { + new->exp_date = old->exp_date; + SET_FIELD(KADM_EXPDATE, new->fields); + } + if (IS_FIELD(KADM_ATTR,fields)) { + new->attributes = old->attributes; + SET_FIELD(KADM_ATTR, new->fields); + } + if (IS_FIELD(KADM_MAXLIFE,fields)) { + new->max_life = old->max_life; + SET_FIELD(KADM_MAXLIFE, new->fields); + } + if (IS_FIELD(KADM_DESKEY,fields)) { + new->key_low = old->key_low; + new->key_high = old->key_high; + SET_FIELD(KADM_DESKEY, new->fields); + } } void kadm_vals_to_prin(u_char *fields, Principal *new, Kadm_vals *old) { - - memset(new, 0, sizeof(*new)); - if (IS_FIELD(KADM_NAME,fields)) - strncpy(new->name, old->name, ANAME_SZ); - if (IS_FIELD(KADM_INST,fields)) - strncpy(new->instance, old->instance, INST_SZ); - if (IS_FIELD(KADM_EXPDATE,fields)) - new->exp_date = old->exp_date; - if (IS_FIELD(KADM_ATTR,fields)) - new->attributes = old->attributes; - if (IS_FIELD(KADM_MAXLIFE,fields)) - new->max_life = old->max_life; - if (IS_FIELD(KADM_DESKEY,fields)) { - new->key_low = old->key_low; - new->key_high = old->key_high; - } + if (new == NULL) + return; + + memset(new, 0, sizeof(*new)); + if (IS_FIELD(KADM_NAME,fields)) { + strncpy(new->name, old->name, ANAME_SZ); + new->name[ANAME_SZ - 1] = '\0'; + } + if (IS_FIELD(KADM_INST,fields)) { + strncpy(new->instance, old->instance, INST_SZ); + new->instance[KADM_INST - 1] = '\0'; + } + if (IS_FIELD(KADM_EXPDATE,fields)) + new->exp_date = old->exp_date; + if (IS_FIELD(KADM_ATTR,fields)) + new->attributes = old->attributes; + if (IS_FIELD(KADM_MAXLIFE,fields)) + new->max_life = old->max_life; + if (IS_FIELD(KADM_DESKEY,fields)) { + new->key_low = old->key_low; + new->key_high = old->key_high; + } } |