Skip to content

Commit

Permalink
fixed improper delete operator usage in normApp.cpp and minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
bebopagogo committed Jan 24, 2024
1 parent a992176 commit 6188965
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
21 changes: 11 additions & 10 deletions src/common/normApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class NormApp : public NormController, public ProtoApp

enum EcnMode {ECN_OFF, ECN_ON, ECN_ONLY};

enum {MSG_BUFFER_SIZE = 65535};

#ifdef UNIX
static void SignalHandler(int sigNum);
#endif // UNIX
Expand All @@ -115,7 +117,7 @@ class NormApp : public NormController, public ProtoApp
FILE* output; // output stream
char* output_io_buffer;
unsigned int output_io_bufsize;
char input_buffer[65535];
char input_buffer[MSG_BUFFER_SIZE];
unsigned int input_index;
unsigned int input_length;
bool input_active;
Expand All @@ -127,7 +129,7 @@ class NormApp : public NormController, public ProtoApp
bool msg_test;
unsigned int msg_test_length;
UINT32 msg_test_seq;
char output_buffer[65535];
char output_buffer[MSG_BUFFER_SIZE];
UINT16 output_index;
bool output_messaging;
UINT16 output_msg_length;
Expand Down Expand Up @@ -161,7 +163,7 @@ class NormApp : public NormController, public ProtoApp
NormSession::ProbingMode grtt_probing_mode;
double group_size;
unsigned long tx_buffer_size; // bytes
unsigned int tx_sock_buffer_size;
unsigned int tx_sock_buffer_size;
unsigned long tx_cache_min;
unsigned long tx_cache_max;
NormObjectSize tx_cache_size;
Expand Down Expand Up @@ -213,7 +215,6 @@ class NormApp : public NormController, public ProtoApp

}; // end class NormApp


NormApp::FileCacheItem::FileCacheItem(const char* thePath)
{
strncpy(file_path, thePath, PATH_MAX);
Expand Down Expand Up @@ -603,7 +604,7 @@ bool NormApp::OnCommand(const char* cmd, const char* val)
else if (!strncmp("address", cmd, len))
{
size_t len = strlen(val);
if (address) delete address;
if (address) delete[] address;
if (!(address = new char[len+1]))
{
PLOG(PL_FATAL, "NormApp::OnCommand(address) allocation error:%s\n",
Expand All @@ -614,7 +615,7 @@ bool NormApp::OnCommand(const char* cmd, const char* val)
char* ptr = strchr(address, '/');
if (!ptr)
{
delete address;
delete[] address;
address = NULL;
PLOG(PL_FATAL, "NormApp::OnCommand(address) missing port number!\n");
return false;
Expand All @@ -623,7 +624,7 @@ bool NormApp::OnCommand(const char* cmd, const char* val)
int portNum = atoi(ptr);
if ((portNum < 1) || (portNum > 65535))
{
delete address;
delete[] address;
address = NULL;
PLOG(PL_FATAL, "NormApp::OnCommand(address) invalid port number!\n");
return false;
Expand Down Expand Up @@ -1405,7 +1406,7 @@ void NormApp::OnInputReady()
{
if (input_msg_length)
{
UINT16 bufferSpace = 65535 - input_index;
UINT16 bufferSpace = MSG_BUFFER_SIZE - input_index;
UINT16 msgRemainder = input_msg_length - input_msg_index;
readLength = MIN(bufferSpace, msgRemainder);
}
Expand All @@ -1418,7 +1419,7 @@ void NormApp::OnInputReady()
memcpy(&input_msg_length, input_buffer, 2);
input_msg_length = ntohs(input_msg_length);
ASSERT(input_msg_length >= 2);
UINT16 bufferSpace = 65535 - input_index;
UINT16 bufferSpace = MSG_BUFFER_SIZE - input_index;
UINT16 msgRemainder = input_msg_length - 2;
readLength = MIN(bufferSpace, msgRemainder);
}
Expand All @@ -1443,7 +1444,7 @@ void NormApp::OnInputReady()
{
hdrOffset = 0;
}
int hdrLen = sprintf(input_buffer + hdrOffset, "NORM Test Msg %08u ", msg_test_seq++);
int hdrLen = snprintf(input_buffer + hdrOffset, MSG_BUFFER_SIZE - hdrOffset, "NORM Test Msg %08u ", msg_test_seq++);
char testChar = 'a' + msg_test_seq % 26;
memset(input_buffer + hdrLen + hdrOffset, testChar, msg_test_length - (hdrLen + hdrOffset));
input_buffer[msg_test_length - 1] = '\n';
Expand Down
2 changes: 2 additions & 0 deletions src/common/normPostProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ NormPostProcessor::~NormPostProcessor()
SetCommand(NULL);
}

/* This was defined/implemented, but unused so commented out (for now)
void NormPostProcessor::GetCommand(char* buffer, unsigned int buflen)
{
if (process_argv && buffer)
Expand Down Expand Up @@ -52,6 +53,7 @@ void NormPostProcessor::GetCommand(char* buffer, unsigned int buflen)
if (buflen > 4) buffer[4] = '\0';
}
} // end NormPostProcessor::GetCommand()
*/

bool NormPostProcessor::SetCommand(const char* cmd)
{
Expand Down
2 changes: 1 addition & 1 deletion src/pynorm/session.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
o"""
pynorm - Python wrapper for NRL's libnorm
By: Tom Wambold <[email protected]>
"""
Expand Down

0 comments on commit 6188965

Please sign in to comment.