From: Luca Boccassi Date: Tue, 7 Apr 2026 23:26:33 +0000 (+0100) Subject: nss-myhostname: use INC_SAFE for buffer index accumulation X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=aaab31d7a05563c5d44d4e6c7fae7a0bd802c45f;p=thirdparty%2Fsystemd.git 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 a05483a921a518fd283e7cb32dc8c8e816b2ab2c --- diff --git a/src/nss-myhostname/nss-myhostname.c b/src/nss-myhostname/nss-myhostname.c index 6a016a1f5cc..601a4198dd8 100644 --- a/src/nss-myhostname/nss-myhostname.c +++ b/src/nss-myhostname/nss-myhostname.c @@ -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 */