From dda89963c8b0c98fef81fdc2b286136929668c4e Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Wed, 7 Feb 2024 21:47:50 -0500 Subject: [PATCH] Added better error checking for IP version --- includes/client.hpp | 2 +- includes/server.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/client.hpp b/includes/client.hpp index a81a360..308aced 100644 --- a/includes/client.hpp +++ b/includes/client.hpp @@ -46,7 +46,7 @@ public: this->address = std::string(address); /* Check to see if the given IP address matches the given ip_ver */ - if ((check_ip_ver(address) == 4 && ip_ver == 6) || (check_ip_ver(address) == 6 && ip_ver == 4)) { + if ((check_ip_ver(address) != 6 && ip_ver == 6) || (check_ip_ver(address) != 4 && ip_ver == 4)) { throw std::invalid_argument("Invalid IP address for given type."); } diff --git a/includes/server.hpp b/includes/server.hpp index 48f2511..b1d9500 100644 --- a/includes/server.hpp +++ b/includes/server.hpp @@ -46,7 +46,7 @@ public: this->address = std::string(address); /* Check to see if the given IP address matches the given ip_ver */ - if ((check_ip_ver(address) == 4 && ip_ver == 6) || (check_ip_ver(address) == 6 && ip_ver == 4)) { + if ((check_ip_ver(address) != 6 && ip_ver == 6) || (check_ip_ver(address) != 4 && ip_ver == 4)) { throw std::invalid_argument("Invalid IP address for given type."); }