@@ -901,26 +901,28 @@ bool User::SharesChannelWith(User* other) const
901901
902902void User::ChangeRealName (const std::string& real)
903903{
904- if (!this ->realname .compare (real))
904+ const auto treal = real.substr (0 , ServerInstance->Config ->Limits .MaxReal );
905+ if (!this ->realname .compare (treal))
905906 return ;
906907
907- FOREACH_MOD (OnChangeRealName, (this , real ));
908+ FOREACH_MOD (OnChangeRealName, (this , treal ));
908909
909- this ->realname .assign (real, 0 , ServerInstance-> Config -> Limits . MaxReal );
910+ this ->realname .assign (treal );
910911 this ->realname .shrink_to_fit ();
911912}
912913
913914void User::ChangeDisplayedHost (const std::string& newhost)
914915{
915- if (GetDisplayedHost () == newhost)
916+ const auto tnewhost = newhost.substr (0 , ServerInstance->Config ->Limits .MaxHost );
917+ if (GetDisplayedHost () == tnewhost)
916918 return ;
917919
918- FOREACH_MOD (OnChangeHost, (this , newhost ));
920+ FOREACH_MOD (OnChangeHost, (this , tnewhost ));
919921
920- if (realhost == newhost )
922+ if (realhost == tnewhost )
921923 this ->displayhost .clear ();
922924 else
923- this ->displayhost .assign (newhost, 0 , ServerInstance-> Config -> Limits . MaxHost );
925+ this ->displayhost .assign (tnewhost );
924926 this ->displayhost .shrink_to_fit ();
925927
926928 this ->InvalidateCache ();
@@ -933,7 +935,8 @@ void User::ChangeRealHost(const std::string& newhost, bool resetdisplay)
933935{
934936 // If the real host is the new host and we are not resetting the
935937 // display host then we have nothing to do.
936- const bool changehost = (realhost != newhost);
938+ const auto tnewhost = newhost.substr (0 , ServerInstance->Config ->Limits .MaxHost );
939+ const bool changehost = (realhost != tnewhost);
937940 if (!changehost && !resetdisplay)
938941 return ;
939942
@@ -944,7 +947,7 @@ void User::ChangeRealHost(const std::string& newhost, bool resetdisplay)
944947
945948 // If the displayhost is the new host or we are resetting it then
946949 // we clear its contents to save memory.
947- else if (displayhost == newhost || resetdisplay)
950+ else if (displayhost == tnewhost || resetdisplay)
948951 displayhost.clear ();
949952
950953 // If we are just resetting the display host then we don't need to
@@ -958,9 +961,9 @@ void User::ChangeRealHost(const std::string& newhost, bool resetdisplay)
958961 // Don't call the OnChangeRealHost event when initialising a user.
959962 const bool initializing = realhost.empty ();
960963 if (!initializing)
961- FOREACH_MOD (OnChangeRealHost, (this , newhost ));
964+ FOREACH_MOD (OnChangeRealHost, (this , tnewhost ));
962965
963- realhost = newhost ;
966+ realhost = tnewhost ;
964967 realhost.shrink_to_fit ();
965968
966969 this ->InvalidateCache ();
@@ -974,7 +977,8 @@ void User::ChangeRealUser(const std::string& newuser, bool resetdisplay)
974977{
975978 // If the real user is the new user and we are not resetting the
976979 // display user then we have nothing to do.
977- const bool changeuser = (realuser != newuser);
980+ const auto tnewuser = newuser.substr (0 , ServerInstance->Config ->Limits .MaxUser );
981+ const bool changeuser = (realuser != tnewuser);
978982 if (!changeuser && !resetdisplay)
979983 return ;
980984
@@ -985,7 +989,7 @@ void User::ChangeRealUser(const std::string& newuser, bool resetdisplay)
985989
986990 // If the displayuser is the new user or we are resetting it then
987991 // we clear its contents to save memory.
988- else if (displayuser == newuser || resetdisplay)
992+ else if (displayuser == tnewuser || resetdisplay)
989993 displayuser.clear ();
990994
991995 // If we are just resetting the display user then we don't need to
@@ -996,9 +1000,9 @@ void User::ChangeRealUser(const std::string& newuser, bool resetdisplay)
9961000 // Don't call the OnChangeRealUser event when initialising a user.
9971001 const bool initializing = realuser.empty ();
9981002 if (!initializing)
999- FOREACH_MOD (OnChangeRealUser, (this , newuser ));
1003+ FOREACH_MOD (OnChangeRealUser, (this , tnewuser ));
10001004
1001- realuser = newuser ;
1005+ realuser = tnewuser ;
10021006 realuser.shrink_to_fit ();
10031007
10041008 this ->InvalidateCache ();
@@ -1010,15 +1014,16 @@ void User::ChangeRealUser(const std::string& newuser, bool resetdisplay)
10101014
10111015void User::ChangeDisplayedUser (const std::string& newuser)
10121016{
1013- if (GetDisplayedUser () == newuser)
1017+ const auto tnewuser = newuser.substr (0 , ServerInstance->Config ->Limits .MaxUser );
1018+ if (GetDisplayedUser () == tnewuser)
10141019 return ;
10151020
1016- FOREACH_MOD (OnChangeUser, (this , newuser ));
1021+ FOREACH_MOD (OnChangeUser, (this , tnewuser ));
10171022
1018- if (realuser == newuser )
1023+ if (realuser == tnewuser )
10191024 this ->displayuser .clear ();
10201025 else
1021- this ->displayuser .assign (newuser, 0 , ServerInstance-> Config -> Limits . MaxUser );
1026+ this ->displayuser .assign (tnewuser );
10221027 this ->displayuser .shrink_to_fit ();
10231028
10241029 this ->InvalidateCache ();
0 commit comments