even more fixes

This commit is contained in:
Walter Julius Hennecke 2011-12-05 16:37:03 +01:00
parent dd6c3b228d
commit b63fa5482f
3 changed files with 113 additions and 4 deletions

View file

@ -2663,8 +2663,8 @@ void CG_NewClientInfo( int clientNum ) {
clientInfo_t newInfo;
const char *configstring;
const char *v;
char *model;
char *skin;
char *model = NULL;
char *skin = NULL;
size_t len;
//int i;

View file

@ -483,6 +483,8 @@ static void CG_EncodeIDFile( void )
int intSubnet[4];
int i, j;
memset(strSubnet, 0, sizeof(strSubnet));
IP = (char *)CG_Argv( 1 );
//IP = "143.163.12.2";
@ -632,6 +634,8 @@ void CG_ShaderStateChanged(void) {
o = CG_ConfigString( CS_SHADERSTATE );
if(!o) return;
while (o && *o) {
n = strstr(o, "=");
if (n && *n) {

View file

@ -903,7 +903,7 @@ char *Q_CleanStr( char *string ) {
return string;
}
#ifdef QVM
void QDECL Com_sprintf( char *dest, int size, const char *fmt, ...) {
int len;
va_list argptr;
@ -922,7 +922,34 @@ void QDECL Com_sprintf( char *dest, int size, const char *fmt, ...) {
}
Q_strncpyz (dest, bigbuffer, size );
}
#else
void QDECL Com_sprintf( char *dest, int size, const char *fmt, ...) {
int len;
va_list argptr;
char *bigbuffer = NULL; // big, but small enough to fit in PPC stack
bigbuffer = (char *)malloc(sizeof(char)*32000);
if(!bigbuffer) {
Com_Printf("Com_sprintf: could not allocate %u bytes for BigBuffer\n", sizeof(char)*32000);
return;
}
memset(bigbuffer, 0, sizeof(bigbuffer));
va_start (argptr,fmt);
len = vsprintf (bigbuffer,fmt,argptr);
va_end (argptr);
if ( len >= sizeof( bigbuffer ) ) {
free(bigbuffer);
Com_Error( ERR_FATAL, "Com_sprintf: overflowed bigbuffer" );
}
if (len >= size) {
Com_Printf ("Com_sprintf: overflow of %i in %i\n", len, size);
Com_Printf("Fmt: %s\n", fmt);
Com_Printf("BigBuffer: %s\n", bigbuffer);
}
Q_strncpyz (dest, bigbuffer, size );
}
#endif
/*
============
@ -1073,6 +1100,9 @@ void Info_RemoveKey( char *s, const char *key ) {
Com_Error( ERR_DROP, "Info_RemoveKey: oversize infostring" );
}
memset(pkey, 0, sizeof(pkey));
memset(value, 0, sizeof(value));
if (strchr (key, '\\')) {
return;
}
@ -1118,7 +1148,7 @@ void Info_RemoveKey( char *s, const char *key ) {
Info_RemoveKey_Big
===================
*/
void Info_RemoveKey_Big( char *s, const char *key ) {
#ifdef QVM
char *start;
char pkey[BIG_INFO_KEY];
char value[BIG_INFO_VALUE];
@ -1167,7 +1197,82 @@ void Info_RemoveKey_Big( char *s, const char *key ) {
}
}
#else
void Info_RemoveKey_Big( char *s, const char *key ) {
char *start;
char *pkey;
char *value;
char *o;
if ( strlen( s ) >= BIG_INFO_STRING ) {
Com_Error( ERR_DROP, "Info_RemoveKey_Big: oversize infostring" );
}
pkey = (char *)malloc(sizeof(char)*BIG_INFO_KEY);
if(!pkey) {
Com_Printf("Info_RemoveKey_Big: could not allocate %u byte\n", sizeof(char)*BIG_INFO_KEY);
return;
}
value = (char *)malloc(sizeof(char)*BIG_INFO_VALUE);
if(!value) {
Com_Printf("Info_RemoveKey_Big: could not allocate %u byte\n", sizeof(char)*BIG_INFO_VALUE);
free(value);
return;
}
if (strchr (key, '\\')) {
free(pkey);
free(value);
return;
}
while (1)
{
start = s;
if (*s == '\\')
s++;
o = pkey;
while (*s != '\\')
{
if (!*s) {
free(value);
free(pkey);
return;
}
*o++ = *s++;
}
*o = 0;
s++;
o = value;
while (*s != '\\' && *s)
{
if (!*s) {
free(pkey);
free(value);
return;
}
*o++ = *s++;
}
*o = 0;
if (!strcmp (key, pkey) )
{
strcpy (start, s); // remove this part
free(value);
free(pkey);
return;
}
if (!*s) {
free(pkey);
free(value);
return;
}
}
free(value);
free(pkey);
}
#endif