From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y3DA4-0004AA-UW for qemu-devel@nongnu.org; Mon, 22 Dec 2014 19:17:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y3D9w-0007fj-6z for qemu-devel@nongnu.org; Mon, 22 Dec 2014 19:17:16 -0500 From: David Gibson Date: Tue, 23 Dec 2014 11:16:58 +1100 Message-Id: <1419293824-2654-3-git-send-email-david@gibson.dropbear.id.au> In-Reply-To: <1419293824-2654-1-git-send-email-david@gibson.dropbear.id.au> References: <1419293824-2654-1-git-send-email-david@gibson.dropbear.id.au> Subject: [Qemu-devel] [PATCHv2 2/8] pseries: Add more parameter validation in RTAS time of day functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: agraf@suse.de, aik@ozlabs.ru, mdroth@us.ibm.com Cc: amit.shah@redhat.com, pbonzini@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson 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 --- 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 e290ac0..13eeab8 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); -- 2.1.0