patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH v3] cmdline: fix dynamic tokens parsing
       [not found] <20171115155402.9967-1-xuemingl@mellanox.com>
@ 2018-01-19 18:16 ` Xueming Li
  2018-01-22 13:13   ` Olivier Matz
  0 siblings, 1 reply; 3+ messages in thread
From: Xueming Li @ 2018-01-19 18:16 UTC (permalink / raw)
  To: Olivier MATZ; +Cc: Xueming Li, dev, Adrien Mazarguil, stable

When using dynamic tokens, the result buffer contains pointers to some
location inside the result buffer. When the content of the temporary
buffer is copied in the final one, these pointers still point to the
temporary buffer.

This works until the temporary buffer is kept intact, but the next
commit introduces a memset() that breaks this assumption.

This commit keeps the successfully parsed buffers, and ensures that the
pointers point to the valid location, by using temp buffer for following
parsing.

Fixes: 9b3fbb051d2e ("cmdline: fix parsing")
Cc: stable@dpdk.org
Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 lib/librte_cmdline/cmdline_parse.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/librte_cmdline/cmdline_parse.c b/lib/librte_cmdline/cmdline_parse.c
index 3e12ee54f..c74b146fc 100644
--- a/lib/librte_cmdline/cmdline_parse.c
+++ b/lib/librte_cmdline/cmdline_parse.c
@@ -263,6 +263,7 @@ cmdline_parse(struct cmdline *cl, const char * buf)
 #ifdef RTE_LIBRTE_CMDLINE_DEBUG
 	char debug_buf[BUFSIZ];
 #endif
+	char *result_buf = result.buf;
 
 	if (!cl || !buf)
 		return CMDLINE_PARSE_BAD_ARGS;
@@ -312,16 +313,14 @@ cmdline_parse(struct cmdline *cl, const char * buf)
 		debug_printf("INST %d\n", inst_num);
 
 		/* fully parsed */
-		tok = match_inst(inst, buf, 0, tmp_result.buf,
-				 sizeof(tmp_result.buf));
+		tok = match_inst(inst, buf, 0, result_buf,
+				 CMDLINE_PARSE_RESULT_BUFSIZE);
 
 		if (tok > 0) /* we matched at least one token */
 			err = CMDLINE_PARSE_BAD_ARGS;
 
 		else if (!tok) {
 			debug_printf("INST fully parsed\n");
-			memcpy(&result, &tmp_result,
-			       sizeof(result));
 			/* skip spaces */
 			while (isblank2(*curbuf)) {
 				curbuf++;
@@ -332,6 +331,7 @@ cmdline_parse(struct cmdline *cl, const char * buf)
 				if (!f) {
 					memcpy(&f, &inst->f, sizeof(f));
 					memcpy(&data, &inst->data, sizeof(data));
+					result_buf = tmp_result.buf;
 				}
 				else {
 					/* more than 1 inst matches */
-- 
2.13.3

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-stable] [PATCH v3] cmdline: fix dynamic tokens parsing
  2018-01-19 18:16 ` [dpdk-stable] [PATCH v3] cmdline: fix dynamic tokens parsing Xueming Li
@ 2018-01-22 13:13   ` Olivier Matz
  2018-01-25 22:14     ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Olivier Matz @ 2018-01-22 13:13 UTC (permalink / raw)
  To: Xueming Li; +Cc: dev, Adrien Mazarguil, stable

On Sat, Jan 20, 2018 at 02:16:10AM +0800, Xueming Li wrote:
> When using dynamic tokens, the result buffer contains pointers to some
> location inside the result buffer. When the content of the temporary
> buffer is copied in the final one, these pointers still point to the
> temporary buffer.
> 
> This works until the temporary buffer is kept intact, but the next
> commit introduces a memset() that breaks this assumption.
> 
> This commit keeps the successfully parsed buffers, and ensures that the
> pointers point to the valid location, by using temp buffer for following
> parsing.
> 
> Fixes: 9b3fbb051d2e ("cmdline: fix parsing")
> Cc: stable@dpdk.org
> Signed-off-by: Xueming Li <xuemingl@mellanox.com>

Acked-by: Olivier Matz <olivier.matz@6wind.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-stable] [PATCH v3] cmdline: fix dynamic tokens parsing
  2018-01-22 13:13   ` Olivier Matz
@ 2018-01-25 22:14     ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2018-01-25 22:14 UTC (permalink / raw)
  To: Xueming Li; +Cc: stable, Olivier Matz, dev, Adrien Mazarguil

22/01/2018 14:13, Olivier Matz:
> On Sat, Jan 20, 2018 at 02:16:10AM +0800, Xueming Li wrote:
> > When using dynamic tokens, the result buffer contains pointers to some
> > location inside the result buffer. When the content of the temporary
> > buffer is copied in the final one, these pointers still point to the
> > temporary buffer.
> > 
> > This works until the temporary buffer is kept intact, but the next
> > commit introduces a memset() that breaks this assumption.
> > 
> > This commit keeps the successfully parsed buffers, and ensures that the
> > pointers point to the valid location, by using temp buffer for following
> > parsing.
> > 
> > Fixes: 9b3fbb051d2e ("cmdline: fix parsing")
> > Cc: stable@dpdk.org
> > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> 
> Acked-by: Olivier Matz <olivier.matz@6wind.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-25 22:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20171115155402.9967-1-xuemingl@mellanox.com>
2018-01-19 18:16 ` [dpdk-stable] [PATCH v3] cmdline: fix dynamic tokens parsing Xueming Li
2018-01-22 13:13   ` Olivier Matz
2018-01-25 22:14     ` Thomas Monjalon

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).