]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
print something on "name" length overflow
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 16 May 2009 17:05:41 +0000 (17:05 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 16 May 2009 17:05:41 +0000 (17:05 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8967 d7cf8633-e32d-0410-b094-e92efae38249

host_cmd.c

index ccf6c5bc5c87d114caede29c5563e27fdae1747d..ea1235ad23c5834462e15f0b819967da9f1e6a7e 100644 (file)
@@ -987,22 +987,29 @@ void Host_Name_f (void)
 {
        int i, j;
        qboolean valid_colors;
+       const char *newNameSource;
        char newName[sizeof(host_client->name)];
 
        if (Cmd_Argc () == 1)
        {
-               Con_Printf("\"name\" is \"%s\"\n", cl_name.string);
+               Con_Printf("name: %s\n", cl_name.string);
                return;
        }
 
        if (Cmd_Argc () == 2)
-               strlcpy (newName, Cmd_Argv(1), sizeof (newName));
+               newNameSource = Cmd_Argv(i);
        else
-               strlcpy (newName, Cmd_Args(), sizeof (newName));
+               newNameSource = Cmd_Args();
 
        if (cmd_source == src_command)
        {
+               strlcpy(newName, newNameSource, sizeof(newName));
                Cvar_Set ("_cl_name", newName);
+               if (strlen(newNameSource) >= sizeof(newName)) // overflowed
+               {
+                       Con_Printf("Your name is longer than %i chars! It has been truncated.\n", sizeof(newName) - 1);
+                       Con_Printf("name: %s\n", cl_name.string);
+               }
                return;
        }