diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-04-20 14:44:46 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-04-20 14:44:46 +0000 |
commit | 771319cccea2e638fabbe3bc1d6483cb616e492e (patch) | |
tree | 4ec240c6875c9da82c6523ae31ab40caf5582273 /kerberosV | |
parent | b1154e18def3ab2e37c97ce0f1c3e1d5ff8f8b09 (diff) |
correct strlpcy; spotted by janj+openbsd@wenf.org
Diffstat (limited to 'kerberosV')
-rw-r--r-- | kerberosV/src/lib/roken/resolve.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/kerberosV/src/lib/roken/resolve.c b/kerberosV/src/lib/roken/resolve.c index 229ddd6ca17..94f821da7c3 100644 --- a/kerberosV/src/lib/roken/resolve.c +++ b/kerberosV/src/lib/roken/resolve.c @@ -116,6 +116,7 @@ parse_reply(unsigned char *data, int len) unsigned char *p; char host[128]; int status; + size_t l; struct dns_reply *r; struct resource_record **rr; @@ -202,14 +203,15 @@ parse_reply(unsigned char *data, int len) dns_free_data(r); return NULL; } + l = strlen(host); /* NUL in struct */ (*rr)->u.mx = (struct mx_record*)malloc(sizeof(struct mx_record) + - strlen(host)); + l); if((*rr)->u.mx == NULL) { dns_free_data(r); return NULL; } (*rr)->u.mx->preference = (p[0] << 8) | p[1]; - strlcpy((*rr)->u.mx->domain, host, strlen(host)); + strlcpy((*rr)->u.mx->domain, host, l + 1); break; } case T_SRV:{ @@ -218,9 +220,9 @@ parse_reply(unsigned char *data, int len) dns_free_data(r); return NULL; } + l = strlen(host); /* NUL in struct */ (*rr)->u.srv = - (struct srv_record*)malloc(sizeof(struct srv_record) + - strlen(host)); + (struct srv_record*)malloc(sizeof(struct srv_record) + l); if((*rr)->u.srv == NULL) { dns_free_data(r); return NULL; @@ -228,7 +230,7 @@ parse_reply(unsigned char *data, int len) (*rr)->u.srv->priority = (p[0] << 8) | p[1]; (*rr)->u.srv->weight = (p[2] << 8) | p[3]; (*rr)->u.srv->port = (p[4] << 8) | p[5]; - strlcpy((*rr)->u.srv->target, host, strlen(host)); + strlcpy((*rr)->u.srv->target, host, l + 1); break; } case T_TXT:{ @@ -267,8 +269,9 @@ parse_reply(unsigned char *data, int len) return NULL; } sig_len = len - 18 - status; + l = strlen(host); /* NUL in struct */ (*rr)->u.sig = malloc(sizeof(*(*rr)->u.sig) - + strlen(host) + sig_len); + + l + sig_len); if ((*rr)->u.sig == NULL) { dns_free_data (r); return NULL; @@ -286,7 +289,7 @@ parse_reply(unsigned char *data, int len) (*rr)->u.sig->sig_len = sig_len; memcpy ((*rr)->u.sig->sig_data, p + 18 + status, sig_len); (*rr)->u.sig->signer = &(*rr)->u.sig->sig_data[sig_len]; - strlcpy((*rr)->u.sig->signer, host, strlen(host)); + strlcpy((*rr)->u.sig->signer, host, l + 1); break; } |