nss-myhostname: use INC_SAFE for buffer index accumulation

Use overflow-safe INC_SAFE() instead of raw addition for idx
accumulation, so that Coverity can see the addition is checked.

CID#1548028

Follow-up for a05483a921
This commit is contained in:
Luca Boccassi
2026-04-08 00:26:33 +01:00
parent 0aaf7e697f
commit aaab31d7a0

View File

@@ -238,14 +238,10 @@ static enum nss_status fill_in_hostent(
if (additional) {
((char**) r_aliases)[0] = r_alias;
((char**) r_aliases)[1] = NULL;
/* Silence static analyzers */
assert(idx <= buflen - 2 * sizeof(char*));
idx += 2*sizeof(char*);
assert_se(INC_SAFE(&idx, 2 * sizeof(char*)));
} else {
((char**) r_aliases)[0] = NULL;
/* Silence static analyzers */
assert(idx <= buflen - sizeof(char*));
idx += sizeof(char*);
assert_se(INC_SAFE(&idx, sizeof(char*)));
}
/* Third, add addresses */