diff options
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 6 | ||||
-rw-r--r-- | winsup/cygwin/dcrt0.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/dlfcn.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/dll_init.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/dll_init.h | 2 | ||||
-rw-r--r-- | winsup/cygwin/exceptions.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_disk_file.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_process.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/path.cc | 26 | ||||
-rw-r--r-- | winsup/cygwin/pinfo.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/pthread.cc | 6 | ||||
-rw-r--r-- | winsup/cygwin/registry.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/spawn.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/strace.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/uinfo.cc | 6 |
15 files changed, 41 insertions, 35 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 6f26816..b46ff25 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +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. diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index fdec9bc..13f7c34 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -528,7 +528,7 @@ break_here () 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; @@ -550,7 +550,7 @@ initial_env () } 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); diff --git a/winsup/cygwin/dlfcn.cc b/winsup/cygwin/dlfcn.cc index fecb328..7ca191b 100644 --- a/winsup/cygwin/dlfcn.cc +++ b/winsup/cygwin/dlfcn.cc @@ -48,7 +48,7 @@ get_full_path_of_dll (const char* str, char *name) 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; diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc index a3817d7..4c3d9a2 100644 --- a/winsup/cygwin/dll_init.cc +++ b/winsup/cygwin/dll_init.cc @@ -103,7 +103,7 @@ dll_list::operator[] (const char *name) 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? */ diff --git a/winsup/cygwin/dll_init.h b/winsup/cygwin/dll_init.h index 5d6c6ab..17e8e3a 100644 --- a/winsup/cygwin/dll_init.h +++ b/winsup/cygwin/dll_init.h @@ -51,7 +51,7 @@ struct dll int count; dll_type type; int namelen; - char name[CYG_MAX_PATH + 1]; + char name[CYG_MAX_PATH]; void detach (); int init (); }; diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 1de0bf9..db8b504 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -131,7 +131,7 @@ error_start_init (const char *buf) 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, '\\')) diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index da89e54..dba3a1b 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -1193,7 +1193,7 @@ fhandler_disk_file::readdir (DIR *dir) 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); diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc index 7fd7110..0454e64 100644 --- a/winsup/cygwin/fhandler_process.cc +++ b/winsup/cygwin/fhandler_process.cc @@ -520,8 +520,8 @@ format_process_maps (_pinfo *p, char *&destbuf, size_t maxsize) 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)) { diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index a728cf8..b9d737d 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -525,7 +525,7 @@ path_conv::check (const char *src, unsigned opt, #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) { @@ -1407,7 +1407,7 @@ mount_item::build_win32 (char *dst, const char *src, unsigned *outflags, unsigne 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); @@ -1731,7 +1731,7 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path, } 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); } @@ -2557,9 +2557,9 @@ symlink_worker (const char *topath, const char *frompath, bool use_winsym, 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; @@ -2612,7 +2612,7 @@ symlink_worker (const char *topath, const char *frompath, bool use_winsym, { if (!isabspath (topath)) { - getcwd (cwd, CYG_MAX_PATH + 1); + getcwd (cwd, CYG_MAX_PATH); if ((cp = strrchr (from, '/')) || (cp = strrchr (from, '\\'))) { c = *cp; @@ -2671,7 +2671,7 @@ symlink_worker (const char *topath, const char *frompath, bool use_winsym, 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; @@ -2686,7 +2686,7 @@ symlink_worker (const char *topath, const char *frompath, bool use_winsym, 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)) @@ -2809,7 +2809,7 @@ symlink_info::check_shortcut (const char *path, HANDLE h) 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'; @@ -2847,7 +2847,7 @@ symlink_info::check_sysfile (const char *path, HANDLE h) /* 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"); @@ -3966,7 +3966,7 @@ etc::file_changed (int n) 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) @@ -4004,7 +4004,7 @@ basename (char *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) diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 5a046f9..1162e7b 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -398,7 +398,7 @@ extern char **__argv; void _pinfo::commune_recv () { - char path[CYG_MAX_PATH + 1]; + char path[CYG_MAX_PATH]; DWORD nr; DWORD code; HANDLE hp; @@ -833,7 +833,7 @@ _pinfo::fd (int fd, size_t &n) 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; diff --git a/winsup/cygwin/pthread.cc b/winsup/cygwin/pthread.cc index 78c7f46..deb7716 100644 --- a/winsup/cygwin/pthread.cc +++ b/winsup/cygwin/pthread.cc @@ -168,8 +168,8 @@ mangle_sem_name (char *mangled, const char *name) 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; @@ -196,7 +196,7 @@ sem_open (const char *name, int oflag, ...) 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); diff --git a/winsup/cygwin/registry.cc b/winsup/cygwin/registry.cc index 25c3a2a..7e99fb8 100644 --- a/winsup/cygwin/registry.cc +++ b/winsup/cygwin/registry.cc @@ -226,7 +226,7 @@ get_registry_hive_path (const char *name, char *path) 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; @@ -238,7 +238,7 @@ get_registry_hive_path (const char *name, char *path) void load_registry_hive (const char * name) { - char path[CYG_MAX_PATH + 1]; + char path[CYG_MAX_PATH]; HKEY hkey; LONG ret; diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 38a2a1e..6aa596e 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -304,7 +304,7 @@ av::unshift (const char *what, int conv) 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); @@ -440,7 +440,7 @@ spawn_guts (const char * prog_arg, const char *const *argv, 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)) { diff --git a/winsup/cygwin/strace.cc b/winsup/cygwin/strace.cc index 6b0b74d..1a73e3d 100644 --- a/winsup/cygwin/strace.cc +++ b/winsup/cygwin/strace.cc @@ -133,7 +133,7 @@ strace::vsprntf (char *buf, const char *func, const char *infmt, va_list ap) 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) diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index 4c5dc23..b023dca 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -251,7 +251,7 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw) 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; @@ -285,7 +285,7 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw) 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); @@ -418,7 +418,7 @@ cygheap_user::env_userprofile (const char *name, size_t namelen) 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); |