+2005-04-03 Corinna Vinschen <corinna@vinschen.de>
+
+ Unify usage of CYG_MAX_PATH throughout. Change buffers from
+ size CYG_MAX_PATH + 1 to CYG_MAX_PATH. Change length tests
+ accordingly.
+
2005-04-02 Christopher Faylor <cgf@timesys.com>
* include/cygwin/version.h: Bump DLL minor number to 15.
static void
initial_env ()
{
- char buf[CYG_MAX_PATH + 1];
+ char buf[CYG_MAX_PATH];
if (GetEnvironmentVariable ("CYGWIN_TESTING", buf, sizeof (buf) - 1))
_cygwin_testing = 1;
}
if (GetEnvironmentVariable ("CYGWIN_DEBUG", buf, sizeof (buf) - 1))
{
- char buf1[CYG_MAX_PATH + 1];
+ char buf1[CYG_MAX_PATH];
len = GetModuleFileName (NULL, buf1, CYG_MAX_PATH);
strlwr (buf1);
strlwr (buf);
int len = strlen (str);
/* empty string or too long to be legal win32 pathname? */
- if (len == 0 || len >= CYG_MAX_PATH - 1)
+ if (len == 0 || len >= CYG_MAX_PATH)
return str; /* Yes. Let caller deal with it. */
const char *ret;
dll *
dll_list::alloc (HINSTANCE h, per_process *p, dll_type type)
{
- char name[CYG_MAX_PATH + 1];
+ char name[CYG_MAX_PATH];
DWORD namelen = GetModuleFileName (h, name, sizeof (name));
/* Already loaded? */
int count;
dll_type type;
int namelen;
- char name[CYG_MAX_PATH + 1];
+ char name[CYG_MAX_PATH];
void detach ();
int init ();
};
return;
}
- char pgm[CYG_MAX_PATH + 1];
+ char pgm[CYG_MAX_PATH];
if (!GetModuleFileName (NULL, pgm, CYG_MAX_PATH))
strcpy (pgm, "cygwin1.dll");
for (char *p = strchr (pgm, '\\'); p; p = strchr (p, '\\'))
int len = strlen (c);
if (strcasematch (c + len - 4, ".lnk"))
{
- char fbuf[CYG_MAX_PATH + 1];
+ char fbuf[CYG_MAX_PATH];
strcpy (fbuf, dir->__d_dirname);
strcpy (fbuf + strlen (fbuf) - 1, c);
path_conv fpath (fbuf, PC_SYM_NOFOLLOW);
DWORD_PTR wset_size;
DWORD_PTR *workingset = NULL;
MODULEINFO info;
- char modname[CYG_MAX_PATH + 1];
- char posix_modname[CYG_MAX_PATH + 1];
+ char modname[CYG_MAX_PATH];
+ char posix_modname[CYG_MAX_PATH];
if (!EnumProcessModules (proc, NULL, 0, &needed))
{
#if 0
static path_conv last_path_conv;
- static char last_src[CYG_MAX_PATH + 1];
+ static char last_src[CYG_MAX_PATH];
if (*last_src && strcmp (last_src, src) == 0)
{
dst[n++] = '\\';
if (!*p || !(flags & MOUNT_ENC))
{
- if ((n + strlen (p)) > CYG_MAX_PATH)
+ if ((n + strlen (p)) >= CYG_MAX_PATH)
err = ENAMETOOLONG;
else
backslashify (p, dst + n, 0);
}
if (mi.flags & MOUNT_ENC)
{
- char tmpbuf[CYG_MAX_PATH + 1];
+ char tmpbuf[CYG_MAX_PATH];
if (fnunmunge (tmpbuf, posix_path))
strcpy (posix_path, tmpbuf);
}
int res = -1;
path_conv win32_path, win32_topath;
char from[CYG_MAX_PATH + 5];
- char cwd[CYG_MAX_PATH + 1], *cp = NULL, c = 0;
- char w32topath[CYG_MAX_PATH + 1];
- char reltopath[CYG_MAX_PATH + 1] = { 0 };
+ char cwd[CYG_MAX_PATH], *cp = NULL, c = 0;
+ char w32topath[CYG_MAX_PATH];
+ char reltopath[CYG_MAX_PATH] = { 0 };
DWORD written;
SECURITY_ATTRIBUTES sa = sec_none_nih;
security_descriptor sd;
{
if (!isabspath (topath))
{
- getcwd (cwd, CYG_MAX_PATH + 1);
+ getcwd (cwd, CYG_MAX_PATH);
if ((cp = strrchr (from, '/')) || (cp = strrchr (from, '\\')))
{
c = *cp;
win_shortcut_hdr *shortcut_header = (win_shortcut_hdr *) buf;
HRESULT hres;
IShellFolder *psl;
- WCHAR wc_path[CYG_MAX_PATH + 1];
+ WCHAR wc_path[CYG_MAX_PATH];
ITEMIDLIST *pidl = NULL, *p;
unsigned short len;
if (SUCCEEDED (hres))
{
MultiByteToWideChar (CP_ACP, 0, w32topath, -1, wc_path,
- CYG_MAX_PATH + 1);
+ CYG_MAX_PATH);
hres = psl->ParseDisplayName (NULL, NULL, wc_path, NULL,
&pidl, NULL);
if (SUCCEEDED (hres))
cp = buf + sizeof (win_shortcut_hdr);
if (file_header->flags & WSH_FLAG_IDLIST) /* Skip ITEMIDLIST */
cp += *(unsigned short *) cp + 2;
- if ((len = *(unsigned short *) cp) == 0 || len > CYG_MAX_PATH)
+ if ((len = *(unsigned short *) cp) == 0 || len >= CYG_MAX_PATH)
goto file_not_symlink;
strncpy (contents, cp += 2, len);
contents[len] = '\0';
/* It's a symlink. */
pflags = PATH_SYMLINK;
- res = ReadFile (h, contents, CYG_MAX_PATH + 1, &got, 0);
+ res = ReadFile (h, contents, CYG_MAX_PATH, &got, 0);
if (!res)
{
debug_printf ("ReadFile2 failed");
extern "C" char *
basename (char *path)
{
- static char buf[CYG_MAX_PATH + 1];
+ static char buf[CYG_MAX_PATH];
char *c, *d, *bs = buf;
if (!path || !*path)
extern "C" char *
dirname (char *path)
{
- static char buf[CYG_MAX_PATH + 1];
+ static char buf[CYG_MAX_PATH];
char *c, *d, *bs = buf;
if (!path || !*path)
void
_pinfo::commune_recv ()
{
- char path[CYG_MAX_PATH + 1];
+ char path[CYG_MAX_PATH];
DWORD nr;
DWORD code;
HANDLE hp;
if (cfd < 0)
s = strdup ("");
else
- s = cfd->get_proc_fd_name ((char *) malloc (CYG_MAX_PATH + 1));
+ s = cfd->get_proc_fd_name ((char *) malloc (CYG_MAX_PATH));
n = strlen (s) + 1;
}
return s;
if (check_null_empty_str_errno (name))
return false;
int len = strlen (name);
- if (len > CYG_MAX_PATH
- || (wincap.has_terminal_services () && len > CYG_MAX_PATH - 7))
+ if (len >= CYG_MAX_PATH
+ || (wincap.has_terminal_services () && len >= CYG_MAX_PATH - 7))
{
set_errno (EINVAL);
return false;
value = va_arg (ap, unsigned int);
va_end (ap);
}
- char mangled_name[CYG_MAX_PATH + 1];
+ char mangled_name[CYG_MAX_PATH];
if (!mangle_sem_name (mangled_name, name))
return NULL;
return semaphore::open (mangled_name, oflag, mode, value);
path[0] = '\0';
if (!RegQueryValueExA (hkey, "ProfileImagePath", 0, &type,
(BYTE *)buf, (siz = sizeof (buf), &siz)))
- ExpandEnvironmentStringsA (buf, path, CYG_MAX_PATH + 1);
+ ExpandEnvironmentStringsA (buf, path, CYG_MAX_PATH);
RegCloseKey (hkey);
if (path[0])
return path;
void
load_registry_hive (const char * name)
{
- char path[CYG_MAX_PATH + 1];
+ char path[CYG_MAX_PATH];
HKEY hkey;
LONG ret;
argv = av;
memmove (argv + 1, argv, (argc + 1) * sizeof (char *));
- char buf[CYG_MAX_PATH + 1];
+ char buf[CYG_MAX_PATH];
if (conv)
{
cygwin_conv_to_posix_path (what, buf);
DWORD done;
- char buf[2 * CYG_MAX_PATH + 1];
+ char buf[2 * CYG_MAX_PATH];
buf[0] = buf[1] = buf[2] = buf[sizeof (buf) - 1] = '\0';
if (!ReadFile (hnd, buf, sizeof (buf) - 1, &done, 0))
{
count = 0;
else
{
- char *p, progname[CYG_MAX_PATH + 1];
+ char *p, progname[CYG_MAX_PATH];
if (!pn)
p = (char *) "*** unknown ***";
else if ((p = strrchr (pn, '\\')) != NULL)
LPUSER_INFO_3 ui = NULL;
WCHAR wuser[UNLEN + 1];
NET_API_STATUS ret;
- char homepath_env_buf[CYG_MAX_PATH + 1];
+ char homepath_env_buf[CYG_MAX_PATH];
char homedrive_env_buf[3];
char *newhomedrive = NULL;
char *newhomepath = NULL;
else
{
char home[CYG_MAX_PATH];
- char buf[CYG_MAX_PATH + 1];
+ char buf[CYG_MAX_PATH];
strcpy (buf, newhomedrive);
strcat (buf, newhomepath);
cygwin_conv_to_full_posix_path (buf, home);
if (test_uid (puserprof, name, namelen))
return puserprof;
- char userprofile_env_buf[CYG_MAX_PATH + 1];
+ char userprofile_env_buf[CYG_MAX_PATH];
char win_id[UNLEN + 1]; /* Large enough for SID */
cfree_and_set (puserprof, almost_null);