From b34504057c0a5c8ddab92f5195184390b2514131 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 5 Dec 2000 16:41:28 +0000 Subject: [PATCH] char *buf; strn.* (..., sizeof(buf) ...) doesn't work so well :/ --- source/cl_demo.c | 2 +- source/cmd.c | 4 ++-- source/pr_cmds.c | 2 +- source/quakefs.c | 6 +++--- source/quakeio.c | 8 +++++--- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/source/cl_demo.c b/source/cl_demo.c index ea76dde..a9dfb53 100644 --- a/source/cl_demo.c +++ b/source/cl_demo.c @@ -745,7 +745,7 @@ play [demoname] */ void CL_PlayDemo_f (void) { - char name[256]; + char name[MAX_OSPATH]; if (Cmd_Argc() != 2) { diff --git a/source/cmd.c b/source/cmd.c index 54a37af..04fc7eb 100644 --- a/source/cmd.c +++ b/source/cmd.c @@ -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; } diff --git a/source/pr_cmds.c b/source/pr_cmds.c index 906f4dc..555f46a 100644 --- a/source/pr_cmds.c +++ b/source/pr_cmds.c @@ -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--) { diff --git a/source/quakefs.c b/source/quakefs.c index 8089997..f66712b 100644 --- a/source/quakefs.c +++ b/source/quakefs.c @@ -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)); } diff --git a/source/quakeio.c b/source/quakeio.c index f6a372e..18e05f5 100644 --- a/source/quakeio.c +++ b/source/quakeio.c @@ -31,12 +31,12 @@ #ifdef HAVE_CONFIG_H # include #endif + #ifdef HAVE_MALLOC_H # include #endif #include #include -#include #include #ifdef WIN32 # include @@ -47,12 +47,14 @@ #ifdef HAVE_UNISTD_H # include #endif - #ifdef _MSC_VER # define _POSIX_ #endif #include +#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); }