char *buf; strn.* (..., sizeof(buf) ...) doesn't work so well :/

This commit is contained in:
Bill Currie 2000-12-05 16:41:28 +00:00
parent eae11661e4
commit b34504057c
5 changed files with 12 additions and 10 deletions

View file

@ -745,7 +745,7 @@ play [demoname]
*/
void CL_PlayDemo_f (void)
{
char name[256];
char name[MAX_OSPATH];
if (Cmd_Argc() != 2)
{

View file

@ -317,8 +317,8 @@ void Cmd_StuffCmds_f (void)
c = com_cmdline[j];
com_cmdline[j] = 0;
strncat (build, com_cmdline+i, sizeof(build) - strlen (build));
strncat (build, "\n", sizeof(build) - strlen (build));
strncat (build, com_cmdline+i, s - strlen (build));
strncat (build, "\n", s - strlen (build));
com_cmdline[j] = c;
i = j-1;
}

View file

@ -722,7 +722,7 @@ void PF_stuffcmd (void)
buf = cl->stufftext_buf;
if (strlen(buf) + strlen(str) >= MAX_STUFFTEXT)
PR_RunError ("stufftext buffer overflow");
strncat (buf, str, sizeof(buf) - strlen (buf));
strncat (buf, str, MAX_STUFFTEXT - strlen (buf));
for (i = strlen(buf); i >= 0; i--)
{

View file

@ -405,7 +405,7 @@ void
COM_CreatePath ( char *path )
{
char *ofs;
char e_path[PATH_MAX];
char e_path[MAX_OSPATH];
Qexpand_squiggle (path, e_path);
path = e_path;
@ -872,7 +872,7 @@ COM_AddDirectory (char *dir)
{
searchpath_t *search;
char *p;
char e_dir[PATH_MAX];
char e_dir[MAX_OSPATH];
Qexpand_squiggle (dir, e_dir);
dir = e_dir;
@ -1145,5 +1145,5 @@ void COM_DefaultExtension (char *path, char *extension)
src--;
}
strncat (path, extension, sizeof(path) - strlen (path));
strncat (path, extension, MAX_OSPATH - strlen (path));
}

View file

@ -31,12 +31,12 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
#include <stdarg.h>
#include <stdlib.h>
#include <quakeio.h>
#include <string.h>
#ifdef WIN32
# include <io.h>
@ -47,12 +47,14 @@
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef _MSC_VER
# define _POSIX_
#endif
#include <limits.h>
#include "quakeio.h"
#include "quakefs.h"
#ifdef WIN32
#ifndef __BORLANDC__
# define setmode _setmode
@ -82,7 +84,7 @@ Qexpand_squiggle(const char *path, char *dest)
if (home) {
strcpy (dest, home);
strncat (dest, path+1, sizeof(dest) - strlen (dest)); // skip leading ~
strncat (dest, path+1, MAX_OSPATH - strlen (dest)); // skip leading ~
} else
strcpy (dest,path);
}