From: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
To: dev@dpdk.org
Cc: olivier.matz@6wind.com, Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
Subject: [dpdk-dev] [PATCH] cmdline: fix unchecked return value
Date: Thu, 14 Apr 2016 15:01:19 +0200 [thread overview]
Message-ID: <1460638879-45680-1-git-send-email-danielx.t.mrzyglod@intel.com> (raw)
This patch is for checking if error values occurs.
fix for coverity errors #13209 & #13195
If the function returns an error value, the error value may be mistaken
for a normal value.
In rdline_char_in: Value returned from a function is not checked for errors
before being used
Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
---
lib/librte_cmdline/cmdline_rdline.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/lib/librte_cmdline/cmdline_rdline.c b/lib/librte_cmdline/cmdline_rdline.c
index 1ef2258..e75a556 100644
--- a/lib/librte_cmdline/cmdline_rdline.c
+++ b/lib/librte_cmdline/cmdline_rdline.c
@@ -377,7 +377,10 @@ rdline_char_in(struct rdline *rdl, char c)
case CMDLINE_KEY_CTRL_K:
cirbuf_get_buf_head(&rdl->right, rdl->kill_buf, RDLINE_BUF_SIZE);
rdl->kill_size = CIRBUF_GET_LEN(&rdl->right);
- cirbuf_del_buf_head(&rdl->right, rdl->kill_size);
+
+ if (cirbuf_del_buf_head(&rdl->right, rdl->kill_size) < 0)
+ return -EINVAL;
+
rdline_puts(rdl, vt100_clear_right);
break;
@@ -496,7 +499,10 @@ rdline_char_in(struct rdline *rdl, char c)
vt100_init(&rdl->vt100);
cirbuf_init(&rdl->left, rdl->left_buf, 0, RDLINE_BUF_SIZE);
cirbuf_init(&rdl->right, rdl->right_buf, 0, RDLINE_BUF_SIZE);
- cirbuf_add_buf_tail(&rdl->left, buf, strnlen(buf, RDLINE_BUF_SIZE));
+
+ if (cirbuf_add_buf_tail(&rdl->left, buf, strnlen(buf, RDLINE_BUF_SIZE)) < 0)
+ return -EINVAL;
+
rdline_redisplay(rdl);
break;
@@ -513,7 +519,10 @@ rdline_char_in(struct rdline *rdl, char c)
vt100_init(&rdl->vt100);
cirbuf_init(&rdl->left, rdl->left_buf, 0, RDLINE_BUF_SIZE);
cirbuf_init(&rdl->right, rdl->right_buf, 0, RDLINE_BUF_SIZE);
- cirbuf_add_buf_tail(&rdl->left, buf, strnlen(buf, RDLINE_BUF_SIZE));
+
+ if (cirbuf_add_buf_tail(&rdl->left, buf, strnlen(buf, RDLINE_BUF_SIZE)) < 0)
+ return -EINVAL;
+
rdline_redisplay(rdl);
break;
@@ -640,7 +649,9 @@ rdline_add_history(struct rdline * rdl, const char * buf)
rdline_remove_old_history_item(rdl);
}
- cirbuf_add_buf_tail(&rdl->history, buf, len);
+ if (cirbuf_add_buf_tail(&rdl->history, buf, len) < 0)
+ return -EINVAL;
+
cirbuf_add_tail(&rdl->history, 0);
return 0;
--
2.5.5
next reply other threads:[~2016-04-14 11:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-14 13:01 Daniel Mrzyglod [this message]
2016-05-02 13:37 ` Olivier Matz
2016-06-28 9:49 ` Mrzyglod, DanielX T
2016-07-01 7:19 ` Olivier MATZ
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=1460638879-45680-1-git-send-email-danielx.t.mrzyglod@intel.com \
--to=danielx.t.mrzyglod@intel.com \
--cc=dev@dpdk.org \
--cc=olivier.matz@6wind.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).