Skip to content

Commit

Permalink
Merge pull request #8 from payload/fix/empty-source-string
Browse files Browse the repository at this point in the history
TuioSource: setSourceString, use strncpy, print empty string is illegal
  • Loading branch information
mkalten authored Nov 23, 2016
2 parents 950cf0e + ab4a963 commit 2b2d3ba
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions TUIO2/TuioSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <sstream>
#include <string.h>
#include <stdlib.h>
#include <iostream>

namespace TUIO2 {

Expand Down Expand Up @@ -131,15 +132,20 @@ namespace TUIO2 {
void setSourceString(const char *src_string) {

char data[128];
strcpy(data,src_string);
strncpy(data,src_string,128);
data[127] = 0;
if ( strlen(data) == 0 ) {
std::cerr << "setSourceString: empty src_string illegal" << std::endl;
return;
}

char *name_inst = strtok(data, "@");

char *addr = strtok(NULL, "@");
if (addr!=NULL) source_address = std::string(addr);
else source_address = (char*)"0x7F000001";

char *name = strtok((char*)name_inst, ":");
char *name = strtok(name_inst, ":");
source_name = std::string(name);

char *inst = strtok(NULL, ":");
Expand Down

0 comments on commit 2b2d3ba

Please sign in to comment.