From 3b8372c1f2ce6546da1d71de2254c18482430e36 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 24 Dec 2015 00:32:54 +0100 Subject: [PATCH] Use TLS buffer in ACL<->text conversion * sec_acl.cc (acltotext32): Use tmp_pathbuf rather than stack buffer. (aclfromtext32): Ditto. Signed-off-by: Corinna Vinschen --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/sec_acl.cc | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 5f9eacffc..c32519efe 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2015-12-24 Corinna Vinschen + + * sec_acl.cc (acltotext32): Use tmp_pathbuf rather than stack buffer. + (aclfromtext32): Ditto. + 2015-12-24 Corinna Vinschen * sec_acl.cc: Cosmetic changes. diff --git a/winsup/cygwin/sec_acl.cc b/winsup/cygwin/sec_acl.cc index dd75e3223..348f0bc6c 100644 --- a/winsup/cygwin/sec_acl.cc +++ b/winsup/cygwin/sec_acl.cc @@ -1432,7 +1432,8 @@ acltotext32 (aclent_t *aclbufp, int aclcnt) set_errno (EINVAL); return NULL; } - char buf[32000]; + tmp_pathbuf tp; + char *buf = tp.c_get (); buf[0] = '\0'; bool first = true; @@ -1502,16 +1503,17 @@ permfromstr (char *perm) extern "C" aclent_t * aclfromtext32 (char *acltextp, int *) { - if (!acltextp) + if (!acltextp || strlen (acltextp) > NT_MAX_PATH) { set_errno (EINVAL); return NULL; } - char buf[strlen (acltextp) + 1]; + tmp_pathbuf tp; aclent_t lacl[MAX_ACL_ENTRIES]; memset (lacl, 0, sizeof lacl); int pos = 0; - strcpy (buf, acltextp); + char *buf = tp.t_get (); + stpcpy (buf, acltextp); char *lasts; cyg_ldap cldap; for (char *c = strtok_r (buf, ",", &lasts);