common: Fix parsing SS control string
PATCH 1/1 common: Fix parsing SS control string
It's not possible to be both greater than '9' and less than '0'. This would lead to accepting things like "#$33#" as activation and "*$33#" as deactivation, even though the string makes no sense.
--- src/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/common.c +1 -1
@@ -554,7 +554,7 @@ gboolean parse_ss_control_string(char *str, int *ss_type, cur =1 ; -if (str[1 ] !='*' && str[1 ] !='#' && str[1 ] >'9' && str[1 ] <'0' ) +if (str[1 ] !='*' && str[1 ] !='#' && (str[1 ] >'9' || str[1 ] <'0' )) goto out;if (str[0 ] =='#' && str[1 ] =='*' )
Signature · 1 line
1.8.2.3
Quoted 12 lines · Lucas De Marchi
It's not possible to be both greater than '9' and less than '0'. This would lead to accepting things like "#$33#" as activation and "*$33#" as deactivation, even though the string makes no sense.
--- src/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)src/common.c +0
-0
src/common.c gboolean parse_ss_control_string(char *str, int *ss_type, · line 558
Quoted 6 lines
src/common.c +1
-1@@ -554,7 +554,7 @@ gboolean parse_ss_control_string(char *str, int *ss_type, cur =1 ; -if (str[1 ] !='*' && str[1 ] !='#' && str[1 ] >'9' && str[1 ] <'0' ) +if (str[1 ] !='*' && str[1 ] !='#' && (str[1 ] >'9' || str[1 ] <'0' )) goto out;
this is actually caught later in the function:
for (i = 0; i < strlen(*sc); i++)
if (!g_ascii_isdigit((*sc)[i]))
goto out;But fixing the check would be good.
Lucas De Marchi
Hi Lucas,
Quoted 12 lines · Lucas De Marchi
It's not possible to be both greater than '9' and less than '0'. This would lead to accepting things like "#$33#" as activation and "*$33#" as deactivation, even though the string makes no sense.
--- src/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)src/common.c +0
-0
src/common.c gboolean parse_ss_control_string(char *str, int *ss_type, · line 557
Quoted 5 lines
src/common.c +1
-1@@ -554,7 +554,7 @@ gboolean parse_ss_control_string(char *str, int *ss_type, cur =1 ; -if (str[1 ] !='*' && str[1 ] !='#' && str[1 ] >'9' && str[1 ] <'0' ) +if (str[1 ] !='*' && str[1 ] !='#' && (str[1 ] >'9' || str[1 ] <'0' ))
Funny how it is hiding in plain sight and nobody has found it in over 4 years. And I think you just got an award for finding the oldest bug :P
Patch has been applied, thanks.
src/common.c gboolean parse_ss_control_string(char *str, int *ss_type, · line 560
Quoted 4 lines
src/common.c +0
-0goto out;if (str[0 ] =='#' && str[1 ] =='*' )
Regards,
-Denis