linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Iker Pedrosa <ikerpedrosam@gmail.com>
To: brgl@bgdev.pl
Cc: Iker Pedrosa <ikerpedrosam@gmail.com>,
	ipedrosa@redhat.com, javierm@redhat.com, perobins@redhat.com,
	linux-gpio@vger.kernel.org, warthog618@gmail.com
Subject: [PATCH libgpiod v2 2/4] lib: line-info strings termination
Date: Mon, 29 Jul 2024 12:57:17 +0200	[thread overview]
Message-ID: <84db7bbe2c84b2d880052a05f8b1cc123d60c2dc.1722250385.git.ikerpedrosam@gmail.com> (raw)
In-Reply-To: <cover.1722250385.git.ikerpedrosam@gmail.com>

strncpy() truncates the destination buffer if it isn't large enough to
hold the copy. Thus, let's increase the size of the destination strings
to add the NULL character at the end.

Signed-off-by: Iker Pedrosa <ikerpedrosam@gmail.com>
---
 lib/line-info.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/line-info.c b/lib/line-info.c
index 9f53b04..a7c6241 100644
--- a/lib/line-info.c
+++ b/lib/line-info.c
@@ -10,9 +10,9 @@
 
 struct gpiod_line_info {
 	unsigned int offset;
-	char name[GPIO_MAX_NAME_SIZE];
+	char name[GPIO_MAX_NAME_SIZE+1];
 	bool used;
-	char consumer[GPIO_MAX_NAME_SIZE];
+	char consumer[GPIO_MAX_NAME_SIZE+1];
 	enum gpiod_line_direction direction;
 	bool active_low;
 	enum gpiod_line_bias bias;
-- 
2.45.2


  parent reply	other threads:[~2024-07-29 10:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-29 10:57 [PATCH libgpiod v2 0/4] Fix issues detected by static analyzer Iker Pedrosa
2024-07-29 10:57 ` [PATCH libgpiod v2 1/4] bindings: python: gpiod: avoid use after free Iker Pedrosa
2024-07-29 10:57 ` Iker Pedrosa [this message]
2024-07-29 10:57 ` [PATCH libgpiod v2 3/4] lib: chip-info strings termination Iker Pedrosa
2024-07-29 10:57 ` [PATCH libgpiod v2 4/4] tools: free to avoid leak Iker Pedrosa
2024-07-31  9:21 ` [PATCH libgpiod v2 0/4] Fix issues detected by static analyzer Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=84db7bbe2c84b2d880052a05f8b1cc123d60c2dc.1722250385.git.ikerpedrosam@gmail.com \
    --to=ikerpedrosam@gmail.com \
    --cc=brgl@bgdev.pl \
    --cc=ipedrosa@redhat.com \
    --cc=javierm@redhat.com \
    --cc=linux-gpio@vger.kernel.org \
    --cc=perobins@redhat.com \
    --cc=warthog618@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).