[systemd-commits] src/nss-mymachines src/nss-resolve
Thomas H.P. Andersen
phomes at kemper.freedesktop.org
Thu Sep 18 15:15:48 PDT 2014
src/nss-mymachines/nss-mymachines.c | 5 +----
src/nss-resolve/nss-resolve.c | 5 +----
2 files changed, 2 insertions(+), 8 deletions(-)
New commits:
commit 66a16e7e9fc501d371b57cbe2ae5d130fe930c6d
Author: Thomas Hindoe Paaboel Andersen <phomes at gmail.com>
Date: Thu Sep 18 23:55:46 2014 +0200
nss: remove dead code
c > 0 is already guaranteed from earlier checks.
We go from
ms = ALIGN(l+1) +
sizeof(char*) +
(c > 0 ? c : 1) * ALIGN(alen) +
(c > 0 ? c+1 : 2) * sizeof(char*);
to
ms = ALIGN(l+1) +
sizeof(char*) +
c * ALIGN(alen) +
(c+1) * sizeof(char*);
to
ms = ALIGN(l+1) + c * ALIGN(alen) + (c+2) * sizeof(char*);
Found by coverity. Fixes: CID#1237570 and CID#1237610
diff --git a/src/nss-mymachines/nss-mymachines.c b/src/nss-mymachines/nss-mymachines.c
index abeb825..9476ad1 100644
--- a/src/nss-mymachines/nss-mymachines.c
+++ b/src/nss-mymachines/nss-mymachines.c
@@ -289,10 +289,7 @@ enum nss_status _nss_mymachines_gethostbyname3_r(
alen = FAMILY_ADDRESS_SIZE(af);
l = strlen(name);
- ms = ALIGN(l+1) +
- sizeof(char*) +
- (c > 0 ? c : 1) * ALIGN(alen) +
- (c > 0 ? c+1 : 2) * sizeof(char*);
+ ms = ALIGN(l+1) + c * ALIGN(alen) + (c+2) * sizeof(char*);
if (buflen < ms) {
*errnop = ENOMEM;
diff --git a/src/nss-resolve/nss-resolve.c b/src/nss-resolve/nss-resolve.c
index 39b7320..6a029a3 100644
--- a/src/nss-resolve/nss-resolve.c
+++ b/src/nss-resolve/nss-resolve.c
@@ -404,10 +404,7 @@ enum nss_status _nss_resolve_gethostbyname3_r(
alen = FAMILY_ADDRESS_SIZE(af);
l = strlen(canonical);
- ms = ALIGN(l+1) +
- sizeof(char*) +
- (c > 0 ? c : 1) * ALIGN(alen) +
- (c > 0 ? c+1 : 2) * sizeof(char*);
+ ms = ALIGN(l+1) + c * ALIGN(alen) + (c+2) * sizeof(char*);
if (buflen < ms) {
*errnop = ENOMEM;
More information about the systemd-commits
mailing list