{
apacket *p = malloc(sizeof(apacket));
if(p == 0) {
- // free only being done to resolve SVACE issue.
- free(p) ;
fatal("failed to allocate an apacket");
}
- memset(p, 0, sizeof(apacket) - MAX_PAYLOAD);
+ memset(p, 0, sizeof(apacket));
return p;
}
if (extcmd != NULL) {
char extbuf[BUF_SIZE] = {0,};
snprintf(extbuf, sizeof extbuf, "::%s", extcmd);
- strncat((char*) cp->data, extbuf, sizeof(cp->data) - strlen((const char*)cp->data)- 1);
+ if ((strlen((const char*)cp->data) + strlen(extbuf) + 1) <= sizeof(cp->data)) {
+ strncat((char*) cp->data, extbuf, sizeof(cp->data) - strlen((const char*)cp->data)- 1);
+ } else {
+ E("Buffer overflow detected while concatenating extcmd\n");
+ }
}
+
cp->msg.data_length = strlen((char*) cp->data) + 1;
D("CNXN data: %s\n", (char*)cp->data);