[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/5] pseries: Add more parameter validation in RTAS
From: |
David Gibson |
Subject: |
[Qemu-devel] [PATCH 3/5] pseries: Add more parameter validation in RTAS time of day functions |
Date: |
Tue, 16 Dec 2014 11:43:46 +1100 |
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 <address@hidden>
---
hw/ppc/spapr_rtc.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/hw/ppc/spapr_rtc.c b/hw/ppc/spapr_rtc.c
index 9ccefbc..fac0017 100644
--- a/hw/ppc/spapr_rtc.c
+++ b/hw/ppc/spapr_rtc.c
@@ -44,7 +44,7 @@ static void rtas_get_time_of_day(PowerPCCPU *cpu,
sPAPREnvironment *spapr,
struct tm tm;
uint32_t ns;
- if (nret != 8) {
+ if ((nargs != 0) || (nret != 8)) {
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
return;
}
@@ -68,6 +68,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);
--
2.1.0
- Re: [Qemu-devel] [PATCH 2/5] pseries: Add spapr_rtc_read() helper function, (continued)
- [Qemu-devel] [PATCH 5/5] pseries: Make RTAS time of day functions respect -rtc options, David Gibson, 2014/12/15
- [Qemu-devel] [PATCH 1/5] pseries: Move sPAPR RTC code into its own file, David Gibson, 2014/12/15
- Re: [Qemu-devel] [PATCH 1/5] pseries: Move sPAPR RTC code into its own file, Alexander Graf, 2014/12/15
- Re: [Qemu-devel] [PATCH 1/5] pseries: Move sPAPR RTC code into its own file, David Gibson, 2014/12/15
- Re: [Qemu-devel] [PATCH 1/5] pseries: Move sPAPR RTC code into its own file, Alexander Graf, 2014/12/16
- Re: [Qemu-devel] [PATCH 1/5] pseries: Move sPAPR RTC code into its own file, David Gibson, 2014/12/18
- Re: [Qemu-devel] [PATCH 1/5] pseries: Move sPAPR RTC code into its own file, Alexander Graf, 2014/12/18
- Re: [Qemu-devel] [PATCH 1/5] pseries: Move sPAPR RTC code into its own file, David Gibson, 2014/12/19
- Re: [Qemu-devel] [PATCH 1/5] pseries: Move sPAPR RTC code into its own file, Alexander Graf, 2014/12/19
[Qemu-devel] [PATCH 3/5] pseries: Add more parameter validation in RTAS time of day functions,
David Gibson <=
[Qemu-devel] [PATCH 4/5] pseries: Export /machine "rtc-time" property, David Gibson, 2014/12/15