aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2015-02-06 14:55:48 +1100
committerAlexander Graf <agraf@suse.de>2015-03-09 14:59:56 +0100
commitbbade20633a6b4ed7333e03a76038eda98950946 (patch)
treeae2aaeaa59643f0c71cd9d159bd299e32a1bc050 /hw
parent12f421745cd763742377c7134f48fa12fb889ee3 (diff)
pseries: Add more parameter validation in RTAS time of day functions
Currently, the RTAS time of day functions only partially validate the number of parameters they receive and return. Because of how the parameters are used, this is unlikely to lead to a crash, but it's messy. This patch adds the missing checks. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'hw')
-rw-r--r--hw/ppc/spapr_rtc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/hw/ppc/spapr_rtc.c b/hw/ppc/spapr_rtc.c
index e290ac0699..13eeab8745 100644
--- a/hw/ppc/spapr_rtc.c
+++ b/hw/ppc/spapr_rtc.c
@@ -36,7 +36,7 @@ static void rtas_get_time_of_day(PowerPCCPU *cpu, sPAPREnvironment *spapr,
{
struct tm tm;
- if (nret != 8) {
+ if ((nargs != 0) || (nret != 8)) {
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
return;
}
@@ -60,6 +60,11 @@ static void rtas_set_time_of_day(PowerPCCPU *cpu, sPAPREnvironment *spapr,
{
struct tm tm;
+ if ((nargs != 7) || (nret != 1)) {
+ rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
+ return;
+ }
+
tm.tm_year = rtas_ld(args, 0) - 1900;
tm.tm_mon = rtas_ld(args, 1) - 1;
tm.tm_mday = rtas_ld(args, 2);