From 8fb2622b66950f39cff7df4b959322196a68bec0 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 26 Feb 2015 17:58:03 -0500 Subject: [PATCH] Throw an exception if the received app list XML was incomplete --- .../src/com/limelight/nvstream/http/NvHTTP.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/moonlight-common/src/com/limelight/nvstream/http/NvHTTP.java b/moonlight-common/src/com/limelight/nvstream/http/NvHTTP.java index 63d99063..3b8fd8f3 100644 --- a/moonlight-common/src/com/limelight/nvstream/http/NvHTTP.java +++ b/moonlight-common/src/com/limelight/nvstream/http/NvHTTP.java @@ -328,6 +328,7 @@ public class NvHTTP { int eventType = xpp.getEventType(); LinkedList appList = new LinkedList(); Stack currentTag = new Stack(); + boolean rootTerminated = false; while (eventType != XmlPullParser.END_DOCUMENT) { switch (eventType) { @@ -342,6 +343,9 @@ public class NvHTTP { break; case (XmlPullParser.END_TAG): currentTag.pop(); + if (xpp.getName().equals("root")) { + rootTerminated = true; + } break; case (XmlPullParser.TEXT): NvApp app = appList.getLast(); @@ -357,6 +361,11 @@ public class NvHTTP { eventType = xpp.next(); } + // Throw a malformed XML exception if we've not seen the root tag ended + if (!rootTerminated) { + throw new XmlPullParserException("Malformed XML: Root tag was not terminated"); + } + // Ensure that all apps in the list are initialized ListIterator i = appList.listIterator(); while (i.hasNext()) {