changeset 8511:f2464da11ade

8159519: Reformat JDWP messages Reviewed-by: dcubed Contributed-by: definedmisbehaviour@saynotolinux.com, daniel.daugherty@oracle.com
author vkempik
date Thu, 07 Jul 2016 15:52:13 +0300
parents 0b55ddd61757
children 6a71656816aa
files src/share/back/debugLoop.c src/share/javavm/export/jdwpTransport.h
diffstat 2 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/back/debugLoop.c	Tue Oct 18 13:19:16 2016 +0100
+++ b/src/share/back/debugLoop.c	Thu Jul 07 15:52:13 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -229,6 +229,20 @@
         if (rc != 0 || (rc == 0 && packet.type.cmd.len == 0)) {
             shouldListen = JNI_FALSE;
             notifyTransportError();
+        } else if (packet.type.cmd.flags != JDWPTRANSPORT_FLAGS_NONE) {
+            /*
+             * Close the connection when we get a jdwpCmdPacket with an
+             * invalid flags field value. This is a protocol violation
+             * so we drop the connection. Also this could be a web
+             * browser generating an HTTP request that passes the JDWP
+             * handshake. HTTP requests requires that everything be in
+             * the ASCII printable range so a flags value of
+             * JDWPTRANSPORT_FLAGS_NONE(0) cannot be generated via HTTP.
+             */
+            ERROR_MESSAGE(("Received jdwpPacket with flags != 0x%d (actual=0x%x) when a jdwpCmdPacket was expected.",
+                           JDWPTRANSPORT_FLAGS_NONE, packet.type.cmd.flags));
+            shouldListen = JNI_FALSE;
+            notifyTransportError();
         } else {
             cmd = &packet.type.cmd;
 
--- a/src/share/javavm/export/jdwpTransport.h	Tue Oct 18 13:19:16 2016 +0100
+++ b/src/share/javavm/export/jdwpTransport.h	Thu Jul 07 15:52:13 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -96,6 +96,11 @@
  */
 
 enum {
+    /*
+     * If additional flags are added that apply to jdwpCmdPacket,
+     * then debugLoop.c: reader() will need to be updated to
+     * accept more than JDWPTRANSPORT_FLAGS_NONE.
+     */
     JDWPTRANSPORT_FLAGS_NONE     = 0x0,
     JDWPTRANSPORT_FLAGS_REPLY    = 0x80
 };