diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2017-03-26 18:41:03 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2017-03-26 18:41:03 +0000 |
commit | b7b97a995d89083783fbdddb11e31f3c1fb8cffd (patch) | |
tree | ecdcd35b1e0e8fce6f01b56c26f507e7af2c0eb0 | |
parent | 03840394c52504381f5b395879594aa4115d5768 (diff) |
recallocarray() for data buffer from the net.
ok beck
-rw-r--r-- | usr.sbin/acme-client/http.c | 12 | ||||
-rw-r--r-- | usr.sbin/acme-client/keyproc.c | 6 | ||||
-rw-r--r-- | usr.sbin/ocspcheck/http.c | 8 |
3 files changed, 15 insertions, 11 deletions
diff --git a/usr.sbin/acme-client/http.c b/usr.sbin/acme-client/http.c index d49cdc8bd10..921668f1add 100644 --- a/usr.sbin/acme-client/http.c +++ b/usr.sbin/acme-client/http.c @@ -1,4 +1,4 @@ -/* $Id: http.c,v 1.19 2017/02/03 08:08:15 guenther Exp $ */ +/* $Id: http.c,v 1.20 2017/03/26 18:41:02 deraadt Exp $ */ /* * Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -422,9 +422,10 @@ http_body_read(const struct http *http, struct httpxfer *trans, size_t *sz) return NULL; else if (ssz == 0) break; - pp = realloc(trans->bbuf, trans->bbufsz + ssz); + pp = recallocarray(trans->bbuf, + trans->bbufsz, trans->bbufsz + ssz, 1); if (pp == NULL) { - warn("realloc"); + warn("recallocarray"); return NULL; } trans->bbuf = pp; @@ -616,9 +617,10 @@ http_head_read(const struct http *http, struct httpxfer *trans, size_t *sz) return NULL; else if (ssz == 0) break; - pp = realloc(trans->hbuf, trans->hbufsz + ssz); + pp = recallocarray(trans->hbuf, + trans->hbufsz, trans->hbufsz + ssz, 1); if (pp == NULL) { - warn("realloc"); + warn("recallocarray"); return NULL; } trans->hbuf = pp; diff --git a/usr.sbin/acme-client/keyproc.c b/usr.sbin/acme-client/keyproc.c index 2ae14e114b5..4f383792b21 100644 --- a/usr.sbin/acme-client/keyproc.c +++ b/usr.sbin/acme-client/keyproc.c @@ -1,4 +1,4 @@ -/* $Id: keyproc.c,v 1.8 2017/01/24 12:53:52 deraadt Exp $ */ +/* $Id: keyproc.c,v 1.9 2017/03/26 18:41:02 deraadt Exp $ */ /* * Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -187,9 +187,9 @@ keyproc(int netsock, const char *keyfile, warn("asprintf"); goto out; } - pp = realloc(sans, sansz + strlen(san)); + pp = recallocarray(sans, sansz, sansz + strlen(san), 1); if (pp == NULL) { - warn("realloc"); + warn("recallocarray"); goto out; } sans = pp; diff --git a/usr.sbin/ocspcheck/http.c b/usr.sbin/ocspcheck/http.c index 456840b391c..6830bacaece 100644 --- a/usr.sbin/ocspcheck/http.c +++ b/usr.sbin/ocspcheck/http.c @@ -1,4 +1,4 @@ -/* $Id: http.c,v 1.8 2017/02/03 08:08:15 guenther Exp $ */ +/* $Id: http.c,v 1.9 2017/03/26 18:41:02 deraadt Exp $ */ /* * Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -422,9 +422,11 @@ http_body_read(const struct http *http, struct httpxfer *trans, size_t *sz) return NULL; else if (ssz == 0) break; - pp = realloc(trans->bbuf, trans->bbufsz + ssz); + + pp = recallocarray(trans->bbuf, + trans->bbufsz, trans->bbufsz + ssz, 1); if (pp == NULL) { - warn("realloc"); + warn("recallocarray"); return NULL; } trans->bbuf = pp; |