develooper Front page | perl.perl5.porters | Postings from September 2000

[ID 20000913.001] Heap corruption in Perl_init_i18nl10n

From:
Alan Burlison
Date:
September 13, 2000 08:28
Subject:
[ID 20000913.001] Heap corruption in Perl_init_i18nl10n
Message ID:
39BF9CE9.3D7FBBDD@uk.sun.com
This is a bug report for perl from alan.burlison@uk.sun.com,
generated with the help of perlbug 1.28 running under perl v5.6.0.


-----------------------------------------------------------------
[Please enter your report here]

The function Perl_init_i18nl10n in utils.c reads junk from the heap on
Solaris,
due to it retaining the values of previous calls to setlocale().  The
manpage
for setlocale says:

     The string returned by setlocale() is such that a subsequent
     call  with  that  string  and  its  associated category will
     restore that part  of  the  program's  locale.   The  string
     returned  must  not  be  modified by the program, but may be
     overwritten by a subsequent call to setlocale().

In the case of Solaris the string returned is to a malloc'd buffer which
is
freed by a subsequent call to setlocale().  If you want to keep the
return value
of setlocale(), a copy should be taken before the next call to
setlocale.

Patch attatched.

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl v5.6.0:

Configured by alanbur at Wed Sep 13 10:07:13 BST 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=solaris, osvers=2.9, archname=sun4-solaris-multi-64int
    uname='sunos mower 5.9 s81_21 sun4u sparc sunw,ultra-60 '
    config_args='-dsOE -Dprefix=/home1/software/perl/debug
-Dinstallprefix=/home1/software/perl/debug
-Dsiteprefix=/home1/software/perl/debug -Doptimize=-g -Duseshrplib
-Uusemymalloc -Ubincompat5005 -Duse64bitint
-Accflags=-DDL_UNLOAD_ALL_AT_EXIT -Dusemultiplicity -Accflags=-DPURIFY'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=define
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=define use64bitall=undef uselongdouble=undef
usesocks=undef
  Compiler:
    cc='cc', optimize='-g', gccversion=
    cppflags='-DDL_UNLOAD_ALL_AT_EXIT -DPURIFY -DDEBUGGING
-I/usr/local/include'
    ccflags ='-DDL_UNLOAD_ALL_AT_EXIT -DPURIFY -DDEBUGGING
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8,
Off_t='off_t', lseeksize=8
    alignbytes=8, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib -L/opt/SUNWspro/WS6/lib '
    libpth=/usr/local/lib /opt/SUNWspro/WS6/lib /lib /usr/lib
/usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt -lsec
    libc=/lib/libc.so, so=so, useshrplib=true, libperl=libperl.so
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='  -R
/home1/software/perl/debug/lib/5.6.0/sun4-solaris-multi-64int/CORE'
    cccdlflags='-KPIC', lddlflags='-G -L/usr/local/lib
-L/opt/SUNWspro/WS6/lib'

Locally applied patches:
    

---
@INC for perl v5.6.0:
    /home1/software/perl/debug/lib/5.6.0/sun4-solaris-multi-64int
    /home1/software/perl/debug/lib/5.6.0
   
/home1/software/perl/debug/lib/site_perl/5.6.0/sun4-solaris-multi-64int
    /home1/software/perl/debug/lib/site_perl/5.6.0
    /home1/software/perl/debug/lib/site_perl
    .

---
Environment for perl v5.6.0:
    HOME=/homedir/rootal
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
   
PATH=/home1/software/perl/debug/bin:/homedir/rootal/bin:/usr/local/bin:/bin:/usr/bin:/usr/sbin:/opt/SUNWspro/bin:/usr/ccs/bin:/opt/gcc/bin:/usr/ucb:/usr/dt/bin:/usr/openwin/bin:/opt/SUNWisdn/bin:/opt/SUNWisdn/tools:.
    PERL_BADLANG (unset)
    SHELL=/bin/ksh


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About