diff options
author | dcubed <none@none> | 2008-03-24 15:14:31 -0700 |
---|---|---|
committer | dcubed <none@none> | 2008-03-24 15:14:31 -0700 |
commit | 3360056852be60119fbab5d4eb344b644327d03d (patch) | |
tree | 93723787d5ace84a7ab20f45d50394f3f95477c6 /src/share/instrument | |
parent | 4e8cec0b6a28da93c1336c447743c4c1b6d04af4 (diff) | |
download | jdk8u_jdk-3360056852be60119fbab5d4eb344b644327d03d.tar.gz |
6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
Summary: Attribute values should be extracted without leading or trailing whitespace.
Reviewed-by: ohair, sspitsyn
Diffstat (limited to 'src/share/instrument')
-rw-r--r-- | src/share/instrument/JarFacade.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/share/instrument/JarFacade.c b/src/share/instrument/JarFacade.c index aef9fa5879..a60bdbee13 100644 --- a/src/share/instrument/JarFacade.c +++ b/src/share/instrument/JarFacade.c @@ -45,11 +45,36 @@ doAttribute(const char* name, const char* value, void* user_data) { if (attribute->name == NULL) { free(attribute); } else { - attribute->value = strdup(value); + char *begin = value; + char *end; + + /* skip any leading white space */ + while (isspace(*begin)) { + begin++; + } + + /* skip any trailing white space */ + end = &begin[strlen(begin)]; + while (end > begin && isspace(end[-1])) { + end--; + } + + if (begin == end) { + /* no value so skip this attribute */ + free(attribute->name); + free(attribute); + return; + } + + size_t value_len = (size_t)(end - begin); + attribute->value = malloc(value_len + 1); if (attribute->value == NULL) { free(attribute->name); free(attribute); } else { + /* save the value without leading or trailing whitespace */ + strncpy(attribute->value, begin, value_len); + attribute->value[value_len] = NULL; attribute->next = NULL; if (context->head == NULL) { context->head = attribute; |