]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - common.c
Just in case, make loadsequence unsigned too.
[xonotic/darkplaces.git] / common.c
index f75d24eafa5d952589000cef62fb945c44a28e36..66b7895a2118c2550dabc8f3bef9e77cfb8b1a99 100644 (file)
--- a/common.c
+++ b/common.c
@@ -1588,7 +1588,7 @@ static void COM_SetGameType(int index)
                // if there are spaces in the game's network filter name it would
                // cause parse errors in getservers in dpmaster, so we need to replace
                // them with _ characters
-               strlcpy(gamenetworkfilternamebuffer, gamenetworkfiltername, sizeof(gamenetworkfiltername));
+               strlcpy(gamenetworkfilternamebuffer, gamenetworkfiltername, sizeof(gamenetworkfilternamebuffer));
                while ((s = strchr(gamenetworkfilternamebuffer, ' ')) != NULL)
                        *s = '_';
                gamenetworkfiltername = gamenetworkfilternamebuffer;
@@ -1619,13 +1619,22 @@ void COM_Init_Commands (void)
                if (strstr(com_argv[j], " "))
                {
                        // arg contains whitespace, store quotes around it
+                       // This condition checks whether we can allow to put
+                       // in two quote characters.
+                       if (n >= ((int)sizeof(com_cmdline) - 2))
+                               break;
                        com_cmdline[n++] = '\"';
-                       while ((n < ((int)sizeof(com_cmdline) - 1)) && com_argv[j][i])
+                       // This condition checks whether we can allow one
+                       // more character and a quote character.
+                       while ((n < ((int)sizeof(com_cmdline) - 2)) && com_argv[j][i])
+                               // FIXME: Doesn't quote special characters.
                                com_cmdline[n++] = com_argv[j][i++];
                        com_cmdline[n++] = '\"';
                }
                else
                {
+                       // This condition checks whether we can allow one
+                       // more character.
                        while ((n < ((int)sizeof(com_cmdline) - 1)) && com_argv[j][i])
                                com_cmdline[n++] = com_argv[j][i++];
                }
@@ -2084,7 +2093,7 @@ void InfoString_SetValue(char *buffer, size_t bufferlength, const char *key, con
                Con_Printf("InfoString_SetValue: no room for \"%s\" \"%s\" in infostring\n", key, value);
                return;
        }
-       if (value && value[0])
+       if (value[0])
        {
                // set the key/value and append the remaining text
                char tempbuffer[MAX_INPUTLINE];
@@ -2287,7 +2296,7 @@ size_t base64_encode(unsigned char *buf, size_t buflen, size_t outbuflen)
        for(i = blocks; i > 0; )
        {
                --i;
-               base64_3to4(buf + 3*i, buf + 4*i, buflen - 3*i);
+               base64_3to4(buf + 3*i, buf + 4*i, (int)(buflen - 3*i));
        }
        return blocks * 4;
 }