From 8359fb8c77d6cf68b8475fc6c3e6daeba1c5866a Mon Sep 17 00:00:00 2001 From: Anton Date: Sun, 12 Nov 2017 18:17:55 +0400 Subject: reject all-zeroes ID --- PICA_node.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/PICA_node.c b/PICA_node.c index a6c5878..79268a6 100644 --- a/PICA_node.c +++ b/PICA_node.c @@ -2470,13 +2470,20 @@ void process_c2n_write() PICA_error("Unable to get client id from certificate"); kill_ptr = i_ptr; } - //PICA_debug2("user id=%u",i_ptr->id); -#warning "see comments below" - //сделать проверку названия сети!!!!---------------------------<<<<<<<<<<<<<<<<<<<<<< X509_free(client_cert); - //прицепить структуру к дереву - if (client_tree_search(i_ptr->id)) + + //reject all-zeroes ID + { + static const char zeroID[PICA_ID_SIZE] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + if (memcmp(zeroID, i_ptr->id, PICA_ID_SIZE) == 0) + { + PICA_error("Rejecting all-zero Pica ID"); + kill_ptr = i_ptr; + } + } + + if (!kill_ptr && client_tree_search(i_ptr->id)) { PICA_info("Disconnecting client %p because other user with same ID = %u is already connected", i_ptr, i_ptr->id); memset(i_ptr->id, 0, PICA_ID_SIZE);//reset id to all zeros to prevent removing existing ID from previous connection from client_tree -- cgit v1.2.1