Bug 74743

Summary: [patch] wctype.c declares static array on stack
Product: Base System Reporter: knut st. osmundsen <bird-freebsd>
Component: binAssignee: Antoine Brodin <antoine>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description knut st. osmundsen 2004-12-05 21:40:18 UTC
The prop array in int wctype() implementation is instanciated on the stack every call.

Sorry if this should be posted elsewhere, but this is my first time on sending a patch. I just happen to come across the code when I shopping code for a OS/2 libc.

Fix: 

wctype_t
 wctype(const char *property)
 {
-       struct {
+       static const struct {
                const char      *name;
                wctype_t         mask;
        } props[] = {
                { "alnum",      _CTYPE_A|_CTYPE_D },
                { "alpha",      _CTYPE_A },--kGq6FqxEU0OCw7umJLIABmM0N3aFbRlhXjKEqn1PpA833gfB
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

Index: wctype.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/locale/wctype.c,v
retrieving revision 1.3
diff -u -5 -r1.3 wctype.c
--- wctype.c    27 Mar 2004 08:59:21 -0000      1.3
+++ wctype.c    5 Dec 2004 21:27:26 -0000
@@ -40,11 +40,11 @@
 }
How-To-Repeat: Call wctype().
Comment 1 Antoine Brodin freebsd_committer freebsd_triage 2008-03-12 18:29:29 UTC
Responsible Changed
From-To: freebsd-bugs->antoine

Take.
Comment 2 dfilter service freebsd_committer freebsd_triage 2008-03-17 18:22:31 UTC
antoine     2008-03-17 18:22:23 UTC

  FreeBSD src repository

  Modified files:
    lib/libc/locale      wctype.c 
  Log:
  Don't allocate the constant array "props" on the stack in wctype.
  
  PR:             74743
  Submitted by:   knut st. osmundsen
  Approved by:    rwatson (mentor)
  MFC after:      1 month
  
  Revision  Changes    Path
  1.4       +1 -1      src/lib/libc/locale/wctype.c
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 3 Antoine Brodin freebsd_committer freebsd_triage 2008-03-17 18:42:00 UTC
State Changed
From-To: open->patched

Patched in HEAD, thanks.
Comment 4 dfilter service freebsd_committer freebsd_triage 2008-04-26 18:38:11 UTC
antoine     2008-04-26 17:38:07 UTC

  FreeBSD src repository

  Modified files:        (Branch: RELENG_7)
    lib/libc/locale      wctype.c 
  Log:
  MFC to RELENG_7:
    Don't allocate the constant array "props" on the stack in wctype.
  
    PR:             74743
    Submitted by:   knut st. osmundsen
    Approved by:    rwatson (mentor)
    MFC after:      1 month
  
  Revision  Changes    Path
  1.3.18.1  +1 -1      src/lib/libc/locale/wctype.c
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 5 dfilter service freebsd_committer freebsd_triage 2008-04-26 18:40:02 UTC
antoine     2008-04-26 17:39:55 UTC

  FreeBSD src repository

  Modified files:        (Branch: RELENG_6)
    lib/libc/locale      wctype.c 
  Log:
  MFC to RELENG_6:
    Don't allocate the constant array "props" on the stack in wctype.
  
    PR:             74743
    Submitted by:   knut st. osmundsen
    Approved by:    rwatson (mentor)
    MFC after:      1 month
  
  Revision  Changes    Path
  1.3.8.1   +1 -1      src/lib/libc/locale/wctype.c
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 6 Antoine Brodin freebsd_committer freebsd_triage 2008-04-26 18:53:16 UTC
State Changed
From-To: patched->closed

Close: fix committed in HEAD, RELENG_7 and RELENG_6. 
Thanks for the report!