Bug 21544

Summary: memory overrun, elf/dl-load.c fillin_rpath()
Product: [Retired] Red Hat Linux Reporter: John Reiser <jreiser>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact: Aaron Brown <abrown>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: fweimer
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-12-08 15:26:37 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description John Reiser 2000-11-30 23:01:29 UTC
If an ELF binary executable has a DT_RPATH that ends in a directory
that requires no dynamic token expansion, and does not have
a trailing '/', and is a directory not seen before,
then fillin_rpath() from glibc-2.2/elf/dl-load.c reads beyond the end
of a block that was allocated by malloc().

Subroutine decompose_rpath() calls at line 531:
  copy = expand_dynamic_string_token (l, rpath);
and at line 548:
  fillin_rpath (copy, result, ":", 0, what, where);
Then fillin_rpath() adds a trailing slash at line 388:
        cp[len++] = '/';
and reads beyond the end at line 422:
          memcpy ((char *) dirp->dirname, cp, len + 1);

One fix is to allocate 2 extra bytes (instead of just 1)
in expand_dynamic_string_token(), and set the last one to '\0'.

Comment 1 Jakub Jelinek 2000-12-19 09:33:44 UTC
Fixed in glibc-2.2-9