X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.7+dev X-Exmh-Isig-CompType: repl X-Exmh-Isig-Folder: inbox From: "karl AT aspodata DOT se [via geda-user AT delorie DOT com]" To: geda-user AT delorie DOT com Subject: Re: [geda-user] strncpy in pcb In-reply-to: <202301312013.30VKDpCR2436099@envy.delorie.com> References: <202301312013 DOT 30VKDpCR2436099 AT envy DOT delorie DOT com> Comments: In-reply-to DJ Delorie message dated "Tue, 31 Jan 2023 15:13:51 -0500." Mime-Version: 1.0 Content-Type: text/plain Message-Id: <20230201135401.50A0B85E50B7@turkos.aspodata.se> Date: Wed, 1 Feb 2023 14:54:01 +0100 (CET) X-Virus-Scanned: ClamAV using ClamSMTP Reply-To: geda-user AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: geda-user AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk DJ Delorie: > This function doesn't do what we really want. If the string to be > copied is the same size as the destination, you end up with a string > that is not NUL terminated. If it's shorter, we waste time padding > the output with unneeded NULs. > > I propose we replace it with pcb_strlcpy (strlcpy does what we want, > but is bsd-specific). ... Regardless if you are using strncpy or strlcpy you have to apply checks to verify that the copy was successful. There are 23 strncpy'ies in pcb. Are you fixing all off them or just fixing a troublesome case ? If the first: Since pcb is using glib, perhaps using its string handling functions would be friutful, or possible any other already written string handling library. If the second: Have you found a bug that isn't handled and gt/named.c is from some upstream, I suggest solving the bug with upstream. Regards, /Karl Hammar