From: tobias Date: Wed, 14 Aug 2024 15:42:18 +0000 (+0000) Subject: Reorder calloc arguments X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=b691e04f32f0eb2256eb58bb40aec926bfc3f12b;p=openbsd Reorder calloc arguments The first argument should be the amount, the second argument should be the element size. Fixing this also silences some gcc compiler warnings for portable. Spotted with Benny Baumann (BenBE at geshi dot org). ok djm@ --- diff --git a/usr.bin/ssh/cipher.c b/usr.bin/ssh/cipher.c index 33f559ae72c..56be78769a3 100644 --- a/usr.bin/ssh/cipher.c +++ b/usr.bin/ssh/cipher.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cipher.c,v 1.121 2024/05/17 02:39:11 jsg Exp $ */ +/* $OpenBSD: cipher.c,v 1.122 2024/08/14 15:42:18 tobias Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -249,7 +249,7 @@ cipher_init(struct sshcipher_ctx **ccp, const struct sshcipher *cipher, #endif *ccp = NULL; - if ((cc = calloc(sizeof(*cc), 1)) == NULL) + if ((cc = calloc(1, sizeof(*cc))) == NULL) return SSH_ERR_ALLOC_FAIL; cc->plaintext = (cipher->flags & CFLAG_NONE) != 0; diff --git a/usr.bin/ssh/sshbuf.c b/usr.bin/ssh/sshbuf.c index d0422d95fa7..668480a343f 100644 --- a/usr.bin/ssh/sshbuf.c +++ b/usr.bin/ssh/sshbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshbuf.c,v 1.22 2024/08/14 15:40:30 tobias Exp $ */ +/* $OpenBSD: sshbuf.c,v 1.23 2024/08/14 15:42:18 tobias Exp $ */ /* * Copyright (c) 2011 Damien Miller * @@ -92,7 +92,7 @@ sshbuf_new(void) { struct sshbuf *ret; - if ((ret = calloc(sizeof(*ret), 1)) == NULL) + if ((ret = calloc(1, sizeof(*ret))) == NULL) return NULL; ret->alloc = SSHBUF_SIZE_INIT; ret->max_size = SSHBUF_SIZE_MAX; @@ -112,7 +112,7 @@ sshbuf_from(const void *blob, size_t len) struct sshbuf *ret; if (blob == NULL || len > SSHBUF_SIZE_MAX || - (ret = calloc(sizeof(*ret), 1)) == NULL) + (ret = calloc(1, sizeof(*ret))) == NULL) return NULL; ret->alloc = ret->size = ret->max_size = len; ret->readonly = 1;