From: Jiri Popelka <jpopelka@redhat.com>
To: netfilter-devel@vger.kernel.org
Cc: "Jaromír Končický" <jkoncick@redhat.com>
Subject: [PATCH 1/2] Error: STRING_NULL
Date: Wed, 2 Oct 2013 10:43:37 +0200 [thread overview]
Message-ID: <1380703418-3067-2-git-send-email-jpopelka@redhat.com> (raw)
In-Reply-To: <1380703418-3067-1-git-send-email-jpopelka@redhat.com>
From: Jaromír Končický <jkoncick@redhat.com>
arptables-v0.0.4/arptables.c:1671: string_null_argument: Function "read(int, void *, size_t)" does not terminate string "*ret".
arptables-v0.0.4/arptables.c:1675: string_null: Passing unterminated string "ret" to "strlen(char const *)", which expects a null-terminated string.
---
userspace/arptables/arptables.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/userspace/arptables/arptables.c b/userspace/arptables/arptables.c
index 5535ab2..8ef445a 100644
--- a/userspace/arptables/arptables.c
+++ b/userspace/arptables/arptables.c
@@ -1668,10 +1668,12 @@ static char *get_modprobe(void)
ret = malloc(1024);
if (ret) {
- switch (read(procfile, ret, 1024)) {
+ int read_bytes = read(procfile, ret, 1024);
+ switch (read_bytes) {
case -1: goto fail;
case 1024: goto fail; /* Partial read. Wierd */
}
+ ret[read_bytes] = '\0';
if (ret[strlen(ret)-1]=='\n')
ret[strlen(ret)-1]=0;
close(procfile);
--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-10-02 8:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-02 8:43 [PATCH 0/2] [arptables] Fixes for problems found by static analysis Jiri Popelka
2013-10-02 8:43 ` Jiri Popelka [this message]
2013-10-02 8:43 ` [PATCH 2/2] Error: STRING_OVERFLOW Jiri Popelka
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=1380703418-3067-2-git-send-email-jpopelka@redhat.com \
--to=jpopelka@redhat.com \
--cc=jkoncick@redhat.com \
--cc=netfilter-devel@vger.kernel.org \
/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).