]> git.proxmox.com Git - mirror_qemu.git/commitdiff
pseries: Add more parameter validation in RTAS time of day functions
authorDavid Gibson <david@gibson.dropbear.id.au>
Fri, 6 Feb 2015 03:55:48 +0000 (14:55 +1100)
committerAlexander Graf <agraf@suse.de>
Mon, 9 Mar 2015 13:59:56 +0000 (14:59 +0100)
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>
hw/ppc/spapr_rtc.c

index e290ac0699cf396e98516bf5b9b23d28db19d290..13eeab8745f8e39a85d473b8a2e42fad8e2ac9da 100644 (file)
@@ -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);