From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTP id 468995A004E for ; Thu, 27 Jun 2024 09:27:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719473260; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q8m+cx+z0MW5C/p+SN0wT1ycRgLyPSSW3HPXxpINpWQ=; b=RUWztx2iDiL6yZ/hKpJZMVu/iGW4SVqbCjNT3wori+atmHiCDNRVtA3E9dcsowp2Z5w/CH LFkE6XzDkkJQq2JYYBRI7TcM6xwVXWkubdoVa8xJ79Cf6T138u0vg4/3gkPsg9e0H9rNgX ivtkZPkh/M0BQjjUpQFjQJX+lH839iQ= Received: from mail-vk1-f199.google.com (mail-vk1-f199.google.com [209.85.221.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-633-RfQKLbsmMoeTmO5Cz4UTHw-1; Thu, 27 Jun 2024 03:27:38 -0400 X-MC-Unique: RfQKLbsmMoeTmO5Cz4UTHw-1 Received: by mail-vk1-f199.google.com with SMTP id 71dfb90a1353d-4ed02be3439so4414102e0c.2 for ; Thu, 27 Jun 2024 00:27:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719473257; x=1720078057; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Q8m+cx+z0MW5C/p+SN0wT1ycRgLyPSSW3HPXxpINpWQ=; b=e6GjN0R5Ls1Wjlg4p4/yOBxHlDCdbrvyVlwyKAp7io9wyoG+8A4HZGrwr6+iSROKSF sUBvSH7hGwQ+eprK0xV91UMA4ERy3dj/TPi/20+8A59b7zY3K6hr8rpWNHqlQMsFq2HI mg09Sgzjfrcsh2/oV1DR2s1fXrN8gsV/FWdaNxa9Dg7PMZIHKFNTIYxRec3oGkVMnpzq Yi+MQ04AEPLabrpIjEX8BVUpU9TUy9tKHomFBKsb1j1il0URfazJ8amnCXnktHR2B29v PsY6jhzS9/moHi3Kc+ujuXRp9UzStKd2jLaTzMcbHFuIzmDMC/NQqQjFdiVtheqJ1tXE iINw== X-Gm-Message-State: AOJu0Yxd2vRNhuW2Um7gWmRK5ZtwGiBbgbJCLcxA/13v3lkVcAf1rZ7P kkafoUIDwkxPaKm4/crQbOOCe0zasPWM5NnckQ9uV6NAmijnFl3naTdFNlkmUuDF0D7Qib/u3Uq StbdbxMUtd6pN66LsuK/2GLxhgcOjrH0vhf6Tnf7ZNL32djNAQQ== X-Received: by 2002:a05:6122:1ad0:b0:4ef:6618:fd5c with SMTP id 71dfb90a1353d-4ef6d7ccbf7mr11547088e0c.3.1719473257318; Thu, 27 Jun 2024 00:27:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1LPgRaK33feDWS78AT3O2FX6ijF4gXFS49I6vwViV42VwMIA1IWFrTS4UEkV6JwdLtcIfSg== X-Received: by 2002:a05:6122:1ad0:b0:4ef:6618:fd5c with SMTP id 71dfb90a1353d-4ef6d7ccbf7mr11547072e0c.3.1719473256744; Thu, 27 Jun 2024 00:27:36 -0700 (PDT) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b592549f98sm2956146d6.72.2024.06.27.00.27.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Jun 2024 00:27:36 -0700 (PDT) Date: Thu, 27 Jun 2024 09:27:01 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 1/4] conf: Copy up to MAXDNSRCH - 1 bytes, not MAXDNSRCH Message-ID: <20240627092653.372a58ea@elisabeth> In-Reply-To: References: <20240626234536.3306466-1-sbrivio@redhat.com> <20240626234536.3306466-2-sbrivio@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: 7YDKQI3QSHKVC6SBJ4GM52Y7DI7WOVDD X-Message-ID-Hash: 7YDKQI3QSHKVC6SBJ4GM52Y7DI7WOVDD X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, Matej Hrica X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Thu, 27 Jun 2024 10:45:28 +1000 David Gibson wrote: > On Thu, Jun 27, 2024 at 01:45:33AM +0200, Stefano Brivio wrote: > > Spotted by Coverity just recently. Not that it really matters as > > MAXDNSRCH always appears to be defined as 1025, while a full domain > > name can have up to 253 characters: it would be a bit pointless to > > have a longer search domain. > > > > Signed-off-by: Stefano Brivio > > Hm. So, IIRC strncpy() won't \0 terminate in the case where it > truncates. I guess we'll get away with that here since we expect > c->dns_search to be filled with \0 before hand. That's... more > fragile than ideal, though. Well, we know we start from a zero-initialised area, that's by design, it's not that we get away with it. Without that consideration not many things would work in this function. Are you suggesting to use snprintf()? It looks a bit pedantic to me but I'm fine with it. Otherwise, feel free to post a patch fixing it in a way you feel it's ideal... > > --- > > conf.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/conf.c b/conf.c > > index e1f5422..9e47e9a 100644 > > --- a/conf.c > > +++ b/conf.c > > @@ -453,7 +453,7 @@ static void get_dns(struct ctx *c) > > while (s - c->dns_search < ARRAY_SIZE(c->dns_search) - 1 > > /* cppcheck-suppress strtokCalled */ > > && (p = strtok(NULL, " \t"))) { > > - strncpy(s->n, p, sizeof(c->dns_search[0])); > > + strncpy(s->n, p, sizeof(c->dns_search[0]) - 1); > > s++; > > *s->n = 0; > > } > -- Stefano