Bug 877540 - Buffer overflow when including commoncpp2 if gethostbyname fails
Summary: Buffer overflow when including commoncpp2 if gethostbyname fails
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: commoncpp2
Version: 18
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: ---
Assignee: Andreas Thienemann
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-11-16 20:13 UTC by Tristan Matthews
Modified: 2014-02-05 13:06 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2014-02-05 13:06:53 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
test case that forces the bug (240 bytes, text/x-c++src)
2012-11-16 20:13 UTC, Tristan Matthews
no flags Details
Fixes buffer overflow error (458 bytes, patch)
2012-11-16 20:15 UTC, Tristan Matthews
no flags Details | Diff

Description Tristan Matthews 2012-11-16 20:13:00 UTC
Created attachment 646572 [details]
test case that forces the bug

Description of problem:

There is a buffer overflow bug in commoncpp2-1.8.1/src/inaddr.cpp (line 336):
            memset((void *)&ipaddr[0], 0, sizeof(ipaddr));

which should be:

            memset((void *)&ipaddr[0], 0, sizeof(ipaddr[0]));


Note that this will only fail on systems where a pointer is larger than the sizeof the ipaddr struct, namely 64 bit systems.

Version-Release number of selected component (if applicable):

Name        : commoncpp2
Arch        : i686
Version     : 1.8.1
Release     : 2.fc17
Size        : 215 k
Repo        : fedora


How reproducible:

Any program that depends on commoncpp2 and runs while gethostbyname is unable to return host info (i.e. connectivity issues) will crash before entering its main function, as this bug happens when initializing a static variable in libcommoncpp2. This affects all 64 bit systems.


Steps to Reproduce:
Compile and run the attached testcase which forces the bug by instantiating a bogus address, using
  
  c++ test.cpp -o test `pkg-config --cflags --libs libccgnu2` -g
  ./test

Actual results:
  The program crashes with a buffer overflow error:
  *** buffer overflow detected ***: ./test terminated


Expected results:
  The program should exit normally.

Additional info:
  I've attached the test case and a patch.

Comment 1 Tristan Matthews 2012-11-16 20:15:57 UTC
Created attachment 646585 [details]
Fixes buffer overflow error

Comment 2 Tristan Matthews 2013-03-12 18:26:52 UTC
This bug is present in Fedora 17 and Fedora 18.

Comment 3 Fedora End Of Life 2013-12-21 09:25:11 UTC
This message is a reminder that Fedora 18 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 18. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '18'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 18's end of life.

Thank you for reporting this issue and we are sorry that we may not be 
able to fix it before Fedora 18 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior to Fedora 18's end of life.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 4 Fedora End Of Life 2014-02-05 13:06:55 UTC
Fedora 18 changed to end-of-life (EOL) status on 2014-01-14. Fedora 18 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.