Changed strtok calls to strtok_r where needed.
This commit is contained in:
Markus Makela
2015-02-16 09:25:41 +02:00
parent cd99d6c1dd
commit 4e5c4c0b6a
3 changed files with 11 additions and 9 deletions

View File

@ -158,6 +158,7 @@ int sendMessage(MYSQL* server, amqp_message_t* msg)
(int)((msg->properties.correlation_id.len + 1)*2+1) +
strlen(DB_INSERT),
rval = 0;
char* saved;
char *qstr = calloc(buffsz,sizeof(char)),
*rawmsg = calloc((msg->body.len + 1),sizeof(char)),
*clnmsg = calloc(((msg->body.len + 1)*2+1),sizeof(char)),
@ -170,9 +171,9 @@ int sendMessage(MYSQL* server, amqp_message_t* msg)
sprintf(qstr,"%.*s",(int)msg->body.len,(char *)msg->body.bytes);
fprintf(out_fd,"Received: %s\n",qstr);
char *ptr = strtok(qstr,"|");
char *ptr = strtok_r(qstr,"|",&saved);
sprintf(rawdate,"%s",ptr);
ptr = strtok(NULL,"\n\0");
ptr = strtok_r(NULL,"\n\0",&saved);
if(ptr == NULL){
fprintf(out_fd,"Message content not valid.\n");
rval = 1;