summaryrefslogtreecommitdiffstats
path: root/PICA_node.c
diff options
context:
space:
mode:
authorAnton <anton@picapica>2017-11-12 18:17:55 +0400
committerAnton <anton@picapica>2017-11-12 18:17:55 +0400
commit8359fb8c77d6cf68b8475fc6c3e6daeba1c5866a (patch)
treeac50e2cf12b8c48c9ec7533789904188ab3f9f5a /PICA_node.c
parentd9566575bf5b09bbb4b6efc7026d1ee7df0965a4 (diff)
downloadpica-pica-8359fb8c77d6cf68b8475fc6c3e6daeba1c5866a.tar.gz
pica-pica-8359fb8c77d6cf68b8475fc6c3e6daeba1c5866a.zip
reject all-zeroes ID
Diffstat (limited to 'PICA_node.c')
-rw-r--r--PICA_node.c17
1 files 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