Skip to content

Commit

Permalink
ACPI: detect invalid argument written to /proc/acpi/alarm
Browse files Browse the repository at this point in the history
/proc/acpi/alarm can't be set correctly, here is a sample:

[root@localhost /]# echo "2006 09" > /proc/acpi/alarm
[root@localhost /]# cat /proc/acpi/alarm
2007-12-09 09:09:09
[root@localhost /]# echo "2006 04" > /proc/acpi/alarm
[root@localhost /]# cat /proc/acpi/alarm
2007-12-04 04:04:04
[root@localhost /]#

Obviously, it is wrong, it should consider it as an invalid input.

after this patch:

[root@localhost /]# echo "2008 09" > /proc/acpi/alarm
-bash: echo: write error: Invalid argument
[root@localhost /]#

Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Signed-off by Yi Yang authored and Len Brown committed Dec 28, 2007
1 parent c68cb23 commit 975c302
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/acpi/sleep/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ static int get_date_field(char **p, u32 * value)
* Try to find delimeter, only to insert null. The end of the
* string won't have one, but is still valid.
*/
if (*p == NULL)
return result;

next = strpbrk(*p, "- :");
if (next)
*next++ = '\0';
Expand All @@ -190,6 +193,8 @@ static int get_date_field(char **p, u32 * value)

if (next)
*p = next;
else
*p = NULL;

return result;
}
Expand Down

0 comments on commit 975c302

Please sign in to comment.