diff mbox

[RESEND] cpufreq: Fix sscanf robustness

Message ID 20131217150723.29514.53369.stgit@alan.etchedpixels.co.uk (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Alan Cox Dec. 17, 2013, 3:07 p.m. UTC
The cpufreq-set tool has a missing length check. This is basically
just correctness but still should get fixed.

One of a set of sscanf problems reported by Jackie Chang

Signed-off-by: Alan Cox <alan@linux.intel.com>
---
 tools/power/cpupower/utils/cpufreq-set.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Rafael J. Wysocki Dec. 22, 2013, 1:05 a.m. UTC | #1
On Tuesday, December 17, 2013 03:07:31 PM Alan wrote:
> The cpufreq-set tool has a missing length check. This is basically
> just correctness but still should get fixed.
> 
> One of a set of sscanf problems reported by Jackie Chang
> 
> Signed-off-by: Alan Cox <alan@linux.intel.com>

Queued up for 3.14 (with a slightly modified changelog).

Thanks,
Rafael


> ---
>  tools/power/cpupower/utils/cpufreq-set.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/power/cpupower/utils/cpufreq-set.c b/tools/power/cpupower/utils/cpufreq-set.c
> index dd1539e..a416de8 100644
> --- a/tools/power/cpupower/utils/cpufreq-set.c
> +++ b/tools/power/cpupower/utils/cpufreq-set.c
> @@ -257,7 +257,7 @@ int cmd_freq_set(int argc, char **argv)
>  				print_unknown_arg();
>  				return -EINVAL;
>  			}
> -			if ((sscanf(optarg, "%s", gov)) != 1) {
> +			if ((sscanf(optarg, "%19s", gov)) != 1) {
>  				print_unknown_arg();
>  				return -EINVAL;
>  			}
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/tools/power/cpupower/utils/cpufreq-set.c b/tools/power/cpupower/utils/cpufreq-set.c
index dd1539e..a416de8 100644
--- a/tools/power/cpupower/utils/cpufreq-set.c
+++ b/tools/power/cpupower/utils/cpufreq-set.c
@@ -257,7 +257,7 @@  int cmd_freq_set(int argc, char **argv)
 				print_unknown_arg();
 				return -EINVAL;
 			}
-			if ((sscanf(optarg, "%s", gov)) != 1) {
+			if ((sscanf(optarg, "%19s", gov)) != 1) {
 				print_unknown_arg();
 				return -EINVAL;
 			}