All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen: fix parse_bool() with empty string
@ 2017-08-25 16:11 Juergen Gross
  2017-08-25 16:15 ` Wei Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Juergen Gross @ 2017-08-25 16:11 UTC (permalink / raw)
  To: xen-devel
  Cc: Juergen Gross, sstabellini, wei.liu2, George.Dunlap,
	andrew.cooper3, ian.jackson, tim, jbeulich

parse_bool() should return -1 in case it is called with an empty
string. In order to allow boolean parameters in the cmdline without
specifying a value this case must be handled in _cmdline_parse() by
always passing a value string.

This fixes commit 532dec8e31174ed450adfd36a4b0b41dec27010d ("xen:
add an optional string end parameter to parse_bool()")

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 xen/common/kernel.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index ec7714961a..71bc547d17 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -114,7 +114,7 @@ static void __init _cmdline_parse(const char *cmdline)
                     simple_strtoll(optval, NULL, 0));
                 break;
             case OPT_BOOL:
-                if ( !parse_bool(optval, NULL) )
+                if ( !parse_bool(*optval ? optval : "yes", NULL) )
                     bool_assert = !bool_assert;
                 assign_integer_param(param, bool_assert);
                 break;
@@ -168,6 +168,8 @@ int __init parse_bool(const char *s, const char *e)
     unsigned int len;
 
     len = e ? ({ ASSERT(e >= s); e - s; }) : strlen(s);
+    if ( !len )
+        return -1;
 
     if ( !strncmp("no", s, len) ||
          !strncmp("off", s, len) ||
-- 
2.12.3


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH] xen: fix parse_bool() with empty string
  2017-08-25 16:11 [PATCH] xen: fix parse_bool() with empty string Juergen Gross
@ 2017-08-25 16:15 ` Wei Liu
  2017-08-25 19:16   ` Andrew Cooper
  0 siblings, 1 reply; 3+ messages in thread
From: Wei Liu @ 2017-08-25 16:15 UTC (permalink / raw)
  To: Juergen Gross
  Cc: tim, sstabellini, wei.liu2, George.Dunlap, andrew.cooper3,
	ian.jackson, xen-devel, jbeulich

On Fri, Aug 25, 2017 at 06:11:25PM +0200, Juergen Gross wrote:
> parse_bool() should return -1 in case it is called with an empty
> string. In order to allow boolean parameters in the cmdline without
> specifying a value this case must be handled in _cmdline_parse() by
> always passing a value string.
> 
> This fixes commit 532dec8e31174ed450adfd36a4b0b41dec27010d ("xen:
> add an optional string end parameter to parse_bool()")
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Acked-by: Wei Liu <wei.liu2@citrix.com>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH] xen: fix parse_bool() with empty string
  2017-08-25 16:15 ` Wei Liu
@ 2017-08-25 19:16   ` Andrew Cooper
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Cooper @ 2017-08-25 19:16 UTC (permalink / raw)
  To: Wei Liu, Juergen Gross
  Cc: sstabellini, George.Dunlap, tim, ian.jackson, xen-devel, jbeulich

On 25/08/17 17:15, Wei Liu wrote:
> On Fri, Aug 25, 2017 at 06:11:25PM +0200, Juergen Gross wrote:
>> parse_bool() should return -1 in case it is called with an empty
>> string. In order to allow boolean parameters in the cmdline without
>> specifying a value this case must be handled in _cmdline_parse() by
>> always passing a value string.
>>
>> This fixes commit 532dec8e31174ed450adfd36a4b0b41dec27010d ("xen:
>> add an optional string end parameter to parse_bool()")
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
> Acked-by: Wei Liu <wei.liu2@citrix.com>

I've exercised this with some of the more weird callers of parse_bool(),
and everything appears to be in order.  Tested, Reviewed and committed,
thanks.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

end of thread, other threads:[~2017-08-25 19:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-25 16:11 [PATCH] xen: fix parse_bool() with empty string Juergen Gross
2017-08-25 16:15 ` Wei Liu
2017-08-25 19:16   ` Andrew Cooper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.