8192978: Missing checks and small fixes in jdwp library

Reviewed-by: cjplummer, sspitsyn
This commit is contained in:
Christoph Langer 2017-12-11 08:20:05 +01:00
parent 18e476899c
commit 03193f6b9b
6 changed files with 20 additions and 24 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2017, 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
@ -839,7 +839,7 @@ writePaths(PacketOutputStream *out, char *string) {
}
pos = string;
for ( i = 0 ; i < npaths ; i++ ) {
for ( i = 0 ; i < npaths && pos != NULL; i++ ) {
char *psPos;
int plen;
@ -859,8 +859,6 @@ writePaths(PacketOutputStream *out, char *string) {
jvmtiDeallocate(buf);
}
static jboolean
classPaths(PacketInputStream *in, PacketOutputStream *out)
{

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2017, 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
@ -71,6 +71,7 @@ vprint_message(FILE *fp, const char *prefix, const char *suffix,
/* Fill buffer with single UTF-8 string */
(void)vsnprintf((char*)utf8buf, sizeof(utf8buf), format, ap);
utf8buf[sizeof(utf8buf) - 1] = 0;
len = (int)strlen((char*)utf8buf);
/* Convert to platform encoding (ignore errors, dangerous area) */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2017, 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
@ -47,7 +47,7 @@ const char * jdwpErrorText(jdwpError);
#define THIS_FILE __FILE__
#endif
#define EXIT_ERROR(error,msg) \
#define EXIT_ERROR(error, msg) \
{ \
print_message(stderr, "JDWP exit error ", "\n", \
"%s(%d): %s [%s:%d]", \
@ -56,21 +56,21 @@ const char * jdwpErrorText(jdwpError);
debugInit_exit((jvmtiError)error, msg); \
}
#define JDI_ASSERT(expression) \
do { \
if (gdata && gdata->assertOn && !(expression)) { \
#define JDI_ASSERT(expression) \
do { \
if (gdata && gdata->assertOn && !(expression)) { \
jdiAssertionFailed(THIS_FILE, __LINE__, #expression); \
} \
} \
} while (0)
#define JDI_ASSERT_MSG(expression, msg) \
do { \
if (gdata && gdata->assertOn && !(expression)) { \
#define JDI_ASSERT_MSG(expression, msg) \
do { \
if (gdata && gdata->assertOn && !(expression)) { \
jdiAssertionFailed(THIS_FILE, __LINE__, msg); \
} \
} \
} while (0)
#define JDI_ASSERT_FAILED(msg) \
#define JDI_ASSERT_FAILED(msg) \
jdiAssertionFailed(THIS_FILE, __LINE__, msg)
void do_pause(void);

View File

@ -471,11 +471,8 @@ synthesizeUnloadEvent(void *signatureVoid, void *envVoid)
jbyte eventSessionID = currentSessionID;
struct bag *eventBag = eventHelper_createEventBag();
if (eventBag == NULL) {
/* TO DO: Report, but don't die
*/
JDI_ASSERT(eventBag != NULL);
}
/* TO DO: Report null error, but don't die */
JDI_ASSERT(eventBag != NULL);
/* Signature needs to last, so convert extra copy to
* classname

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2017, 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
@ -808,7 +808,6 @@ invoker_completeInvokeRequest(jthread thread)
mustReleaseReturnValue = request->invokeType == INVOKE_CONSTRUCTOR ||
returnTypeTag(request->methodSignature) == JDWP_TAG(OBJECT) ||
returnTypeTag(request->methodSignature) == JDWP_TAG(ARRAY);
}
/*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2017, 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
@ -187,6 +187,7 @@ log_message_end(const char *format, ...)
/* Construct message string. */
va_start(ap, format);
(void)vsnprintf(message, sizeof(message), format, ap);
message[sizeof(message) - 1] = 0;
va_end(ap);
get_time_stamp(datetime, sizeof(datetime));