Giter Club home page Giter Club logo

Comments (2)

GoogleCodeExporter avatar GoogleCodeExporter commented on September 10, 2024
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 [email protected] on 20 Feb 2013 at 11:37

from java-simple-serial-connector.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 10, 2024
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 [email protected] on 12 Mar 2013 at 7:45

  • Changed state: Fixed

from java-simple-serial-connector.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.