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
This commit is contained in:
Thomas Hindoe Paaboel Andersen 2014-09-18 23:55:46 +02:00
parent 2f905e821e
commit 66a16e7e9f
2 changed files with 2 additions and 8 deletions

View file

@ -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;

View file

@ -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;