diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index d35588ac6..dc24516a3 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,26 @@ +2007-12-06 Corinna Vinschen + + * dcrt0.cc (initial_env): Use PATH_MAX instead of CYG_MAX_PATH for path + name buffer size. + (dll_crt0_1): Allocate new_argv0 with PATH_MAX size. + * exceptions.cc (debugger_command): Set size to 2 * PATH_MAX + 20; + (error_start_init): Use PATH_MAX instead of CYG_MAX_PATH for path + name buffer size. + * external.cc (fillout_pinfo): Always fill out ep.progname 0-terminated. + Fill out ep.progname_long. + * fhandler_process.cc (fhandler_process::fill_filebuf): Allocate + buffer for executable filename with PATH_MAX size. + * pinfo.cc: Throughout use PATH_MAX instead of CYG_MAX_PATH. + * pinfo.h (class _pinfo): Set progname size to PATH_MAX. + * smallprint.cc: Include limits.h. Use PATH_MAX instead of CYG_MAX_PATH + for path name buffer size. + * strace.cc (strace::vsprntf): Ditto. + * include/sys/cygwin.h (EXTERNAL_PINFO_VERSION_32_LP): Define. + (EXTERNAL_PINFO_VERSION): Set to EXTERNAL_PINFO_VERSION_32_LP. + (struct external_pinfo): Add progname_long member. + * include/sys/dirent.h: Correctly include limits.h instead of + sys/limits.h. + 2007-12-05 Corinna Vinschen * fhandler_tty.cc (fhandler_tty_slave::open): Use MAX_PATH instead of diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index bb4a2c1d5..ca4331cf8 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -542,7 +542,7 @@ break_here () static void initial_env () { - char buf[CYG_MAX_PATH]; + char buf[PATH_MAX]; if (GetEnvironmentVariable ("CYGWIN_TESTING", buf, sizeof (buf) - 1)) _cygwin_testing = 1; @@ -553,7 +553,7 @@ initial_env () { DWORD ms = atoi (buf); buf[0] = '\0'; - len = GetModuleFileName (NULL, buf, CYG_MAX_PATH); + len = GetModuleFileName (NULL, buf, PATH_MAX); console_printf ("Sleeping %d, pid %u %s\n", ms, GetCurrentProcessId (), buf); Sleep (ms); if (!strace.active () && !dynamically_loaded) @@ -561,8 +561,8 @@ initial_env () } if (GetEnvironmentVariable ("CYGWIN_DEBUG", buf, sizeof (buf) - 1)) { - char buf1[CYG_MAX_PATH]; - len = GetModuleFileName (NULL, buf1, CYG_MAX_PATH); + char buf1[PATH_MAX]; + len = GetModuleFileName (NULL, buf1, PATH_MAX); strlwr (buf1); strlwr (buf); char *p = strpbrk (buf, ":="); @@ -871,7 +871,7 @@ dll_crt0_1 (void *) win32 style. */ if ((strchr (__argv[0], ':')) || (strchr (__argv[0], '\\'))) { - char *new_argv0 = (char *) malloc (CYG_MAX_PATH); + char *new_argv0 = (char *) malloc (PATH_MAX); cygwin_conv_to_posix_path (__argv[0], new_argv0); __argv[0] = (char *) realloc (new_argv0, strlen (new_argv0) + 1); } diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index e3569ce23..d030f130d 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -35,7 +35,7 @@ details. */ #define CALL_HANDLER_RETRY 20 -char debugger_command[2 * CYG_MAX_PATH + 20]; +char debugger_command[2 * PATH_MAX + 20]; extern "C" { extern void sigdelayed (); @@ -118,8 +118,8 @@ error_start_init (const char *buf) return; } - char pgm[CYG_MAX_PATH]; - if (!GetModuleFileName (NULL, pgm, CYG_MAX_PATH)) + char pgm[PATH_MAX]; + if (!GetModuleFileName (NULL, pgm, PATH_MAX)) strcpy (pgm, "cygwin1.dll"); for (char *p = strchr (pgm, '\\'); p; p = strchr (p, '\\')) *p = '/'; diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc index ea7ae114e..cc080d2d2 100644 --- a/winsup/cygwin/external.cc +++ b/winsup/cygwin/external.cc @@ -88,7 +88,8 @@ fillout_pinfo (pid_t pid, int winpid) ep.start_time = p->start_time; ep.rusage_self = p->rusage_self; ep.rusage_children = p->rusage_children; - strcpy (ep.progname, p->progname); + ep.progname[0] = '\0'; + strncat (ep.progname, p->progname, MAX_PATH - 1); ep.strace_mask = 0; ep.version = EXTERNAL_PINFO_VERSION; @@ -96,6 +97,8 @@ fillout_pinfo (pid_t pid, int winpid) ep.uid32 = p->uid; ep.gid32 = p->gid; + + strcpy (ep.progname_long, p->progname); break; } } diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc index 916c0dbf3..8f9c9bd04 100644 --- a/winsup/cygwin/fhandler_process.cc +++ b/winsup/cygwin/fhandler_process.cc @@ -442,7 +442,7 @@ fhandler_process::fill_filebuf () case PROCESS_EXENAME: case PROCESS_EXE: { - filebuf = (char *) crealloc_abort (filebuf, bufalloc = CYG_MAX_PATH); + filebuf = (char *) crealloc_abort (filebuf, bufalloc = PATH_MAX); if (p->process_state & PID_EXITED) strcpy (filebuf, ""); else diff --git a/winsup/cygwin/include/sys/cygwin.h b/winsup/cygwin/include/sys/cygwin.h index 7fe4a1377..80d31cd39 100644 --- a/winsup/cygwin/include/sys/cygwin.h +++ b/winsup/cygwin/include/sys/cygwin.h @@ -226,7 +226,8 @@ extern int cygwin_attach_handle_to_fd (char *, int, HANDLE, mode_t, DWORD); #define EXTERNAL_PINFO_VERSION_16_BIT 0 #define EXTERNAL_PINFO_VERSION_32_BIT 1 -#define EXTERNAL_PINFO_VERSION EXTERNAL_PINFO_VERSION_32_BIT +#define EXTERNAL_PINFO_VERSION_32_LP 2 +#define EXTERNAL_PINFO_VERSION EXTERNAL_PINFO_VERSION_32_LP #ifndef _SYS_TYPES_H typedef unsigned short __uid16_t; @@ -262,6 +263,9 @@ struct external_pinfo /* Only available if version >= EXTERNAL_PINFO_VERSION_32_BIT */ __uid32_t uid32; __gid32_t gid32; + + /* Only available if version >= EXTERNAL_PINFO_VERSION_32_LP */ + char progname_long[PATH_MAX]; }; #endif /*__CYGWIN__*/ #endif /*WINVER*/ diff --git a/winsup/cygwin/include/sys/dirent.h b/winsup/cygwin/include/sys/dirent.h index e62cd9249..41bfcc11d 100644 --- a/winsup/cygwin/include/sys/dirent.h +++ b/winsup/cygwin/include/sys/dirent.h @@ -12,7 +12,7 @@ #define _SYS_DIRENT_H #include -#include +#include #define __DIRENT_VERSION 2 diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index b7d8a6dec..d1565f80d 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -392,7 +392,7 @@ DWORD WINAPI commune_process (void *arg) { siginfo_t& si = *((siginfo_t *) arg); - char path[CYG_MAX_PATH]; + char path[PATH_MAX]; DWORD nr; HANDLE& tothem = si._si_commune._si_write_handle; HANDLE process_sync = @@ -439,8 +439,7 @@ commune_process (void *arg) case PICOM_CWD: { sigproc_printf ("processing PICOM_CWD"); - unsigned int n = strlen (cygheap->cwd.get (path, 1, 1, - CYG_MAX_PATH)) + 1; + unsigned int n = strlen (cygheap->cwd.get (path, 1, 1, PATH_MAX)) + 1; if (!WriteFile (tothem, &n, sizeof n, &nr, NULL)) sigproc_printf ("WriteFile sizeof cwd failed, %E"); else if (!WriteFile (tothem, path, n, &nr, NULL)) @@ -571,7 +570,7 @@ _pinfo::commune_request (__uint32_t code, ...) } locked = true; - char name_buf[CYG_MAX_PATH]; + char name_buf[MAX_PATH]; request_sync = CreateSemaphore (&sec_none_nih, 0, LONG_MAX, shared_name (name_buf, "commune", myself->pid)); if (!request_sync) @@ -666,7 +665,7 @@ _pinfo::fd (int fd, size_t &n) if (cfd < 0) s = cstrdup (""); else - s = cfd->get_proc_fd_name ((char *) cmalloc_abort (HEAP_COMMUNE, CYG_MAX_PATH)); + s = cfd->get_proc_fd_name ((char *) cmalloc_abort (HEAP_COMMUNE, PATH_MAX)); n = strlen (s) + 1; } return s; @@ -737,8 +736,8 @@ _pinfo::cwd (size_t& n) } else { - s = (char *) cmalloc_abort (HEAP_COMMUNE, CYG_MAX_PATH); - cygheap->cwd.get (s, 1, 1, CYG_MAX_PATH); + s = (char *) cmalloc_abort (HEAP_COMMUNE, PATH_MAX); + cygheap->cwd.get (s, 1, 1, PATH_MAX); n = strlen (s) + 1; } return s; diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h index b6b46e6b8..3c5e100fb 100644 --- a/winsup/cygwin/pinfo.h +++ b/winsup/cygwin/pinfo.h @@ -64,7 +64,7 @@ public: DWORD dwProcessId; /* Used to spawn a child for fork(), among other things. */ - char progname[CYG_MAX_PATH]; + char progname[PATH_MAX]; /* User information. The information is derived from the GetUserName system call, diff --git a/winsup/cygwin/smallprint.cc b/winsup/cygwin/smallprint.cc index bdf50288b..9208947e2 100644 --- a/winsup/cygwin/smallprint.cc +++ b/winsup/cygwin/smallprint.cc @@ -13,6 +13,7 @@ details. */ #include #include #include +#include #define LLMASK (0xffffffffffffffffULL) #define LMASK (0xffffffff) @@ -63,7 +64,7 @@ __rn (char *dst, int base, int dosign, long long val, int len, int pad, unsigned extern "C" int __small_vsprintf (char *dst, const char *fmt, va_list ap) { - char tmp[CYG_MAX_PATH + 1]; + char tmp[PATH_MAX]; char *orig = dst; const char *s; PWCHAR w; @@ -168,7 +169,7 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap) dst = rnargLL (dst, 16, 0, len, pad); break; case 'P': - if (!GetModuleFileName (NULL, tmp, CYG_MAX_PATH)) + if (!GetModuleFileName (NULL, tmp, PATH_MAX)) s = "cygwin program"; else s = tmp; diff --git a/winsup/cygwin/strace.cc b/winsup/cygwin/strace.cc index 8c778937e..c29a8de2d 100644 --- a/winsup/cygwin/strace.cc +++ b/winsup/cygwin/strace.cc @@ -154,7 +154,7 @@ strace::vsprntf (char *buf, const char *func, const char *infmt, va_list ap) pn = NULL; char *p; - char progname[CYG_MAX_PATH]; + char progname[PATH_MAX]; if (!pn) GetModuleFileName (NULL, pn = progname, sizeof (progname)); if (!pn)