Closed GoogleCodeExporter closed 9 years ago
OK, a few updates here.
The issue I pointed out above is a real issue, but is not the cause of the
behaviour I was seeing.
The root cause of the dump was that the String comport that I was passing in
was actually null, but I was assuming it was legitimate. In that case I was
running into issue #22.
However, the strcat issue above is still relevant. I changed the library code
to look like this to confirm the issue:
<jssc.cpp>
char other[] = "testingTESTINGtestingTESTING";
char prefix[] = "\\\\.\\";
printf("Before:");
printf(other);
printf("\n\r");
fflush(stdout);
const char* port = (const char*)env->GetStringUTFChars(portName, JNI_FALSE);
strcat(prefix, port);
printf("After:");
printf(other);
printf("\n\r");
fflush(stdout);
<end of changes to jssc.cpp>
And the output I get is
Before:testingTESTINGtestingTESTING
After:OM1
This is showing that the strcat is overwriting random stuff on the stack.
Original comment by charles....@gmail.com
on 20 Feb 2013 at 11:37
String concatenation fixed. Version 2.1.0
The correct code should looks like that:
char prefix[] = "\\\\.\\";
const char* port = env->GetStringUTFChars(portName, JNI_FALSE);
char portFullName[strlen(prefix) + strlen(port) + 1];
strcpy(portFullName, prefix);
strcat(portFullName, port);
Original comment by scream3r.org@gmail.com
on 12 Mar 2013 at 7:45
Original issue reported on code.google.com by
charles....@gmail.com
on 20 Feb 2013 at 7:10Attachments: