Skip to content

Commit

Permalink
HPCC-30956 Prevent an invalid trusted_peer from crashing the system
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday committed Dec 1, 2023
1 parent b330baf commit 5354e51
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions system/security/securesocket/securesocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1413,34 +1413,28 @@ class CSecureSocketContext : implements ISecureSocketContext, implements ISecure
if(onepeerbuf.length() == 0)
break;

char* onepeer = onepeerbuf.detach();
const char * onepeer = onepeerbuf.str();
if (isdigit(*onepeer))
{
char *dash = strrchr(onepeer, '-');
if (dash)
const char *dash = strrchr(onepeer, '-');
const char *dot = strrchr(onepeer, '.');
//Allow a range in the form a.b.c.d-e
if (dash && dot && dot < dash)
{
*dash = 0;
int last = atoi(dash+1);
char *dot = strrchr(onepeer, '.');
*dot = 0;
int first = atoi(dot+1);
int last = atoi(dash+1);
for (int i = first; i <= last; i++)
{
StringBuffer t;
t.append(onepeer).append('.').append(i);
t.append(dot-onepeer, onepeer).append('.').append(i);
m_peers->add(t.str());
}
}
else
{
m_peers->add(onepeer);
}
}
else
{
m_peers->add(onepeer);
}
free(onepeer);
}
}
}
Expand Down

0 comments on commit 5354e51

Please sign in to comment.