Bug 485032 - use delete[] to free memory allocated by new[]
Summary: use delete[] to free memory allocated by new[]
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: coolkey
Version: 11
Hardware: All
OS: Linux
high
medium
Target Milestone: ---
Assignee: Jack Magne
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: F12Target 501138
TreeView+ depends on / blocked
 
Reported: 2009-02-11 09:34 UTC by Kamil Dudka
Modified: 2010-06-29 19:35 UTC (History)
4 users (show)

Fixed In Version: coolkey-1_1_0-11_fc12
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 555025 (view as bug list)
Environment:
Last Closed: 2010-06-28 11:15:24 UTC
Type: ---


Attachments (Terms of Use)
easy fix (554 bytes, patch)
2009-02-11 09:34 UTC, Kamil Dudka
no flags Details | Diff
fix for yet another occurrence (342 bytes, patch)
2009-04-14 17:15 UTC, Stanislav Brabec
no flags Details | Diff

Description Kamil Dudka 2009-02-11 09:34:32 UTC
Created attachment 331542 [details]
easy fix

Description of problem:
undefined behavior of invalid delete

Version-Release number of selected component (if applicable):
coolkey-1.1.0-7.fc11

Actual results:
valgrind reports Mismatched free() / delete / delete []

Comment 1 Kamil Dudka 2009-02-11 10:59:48 UTC
Valgrind output with debug info:
==29696== Mismatched free() / delete / delete []
==29696==    at 0x40054AA: operator delete(void*) (vg_replace_malloc.c:342)
==29696==    by 0x418A097: SlotMemSegment::SlotMemSegment(char const*) (slot.cpp:1459)
==29696==    by 0x418CAF5: Slot::Slot(char const*, Log*, _CKYCardContext*) (slot.cpp:335)
==29696==    by 0x418D241: SlotList::updateSlotList() (slot.cpp:143)
==29696==    by 0x418D439: SlotList::SlotList(Log*) (slot.cpp:74)
==29696==    by 0x41827D7: C_Initialize (coolkey.cpp:239)
==29696==    by 0x403D5CF: secmod_ModuleInit (pk11load.c:164)
==29696==    by 0x403DB97: SECMOD_LoadPKCS11Module (pk11load.c:378)
==29696==    by 0x4050FDA: SECMOD_LoadModule (pk11pars.c:323)
==29696==    by 0x405116E: SECMOD_LoadModule (pk11pars.c:338)
==29696==    by 0x401DBF1: nss_Init (nssinit.c:536)
==29696==    by 0x401E1BC: NSS_Initialize (nssinit.c:653)
==29696==  Address 0x428df08 is 0 bytes inside a block of size 24 alloc'd
==29696==    at 0x4005E1E: operator new[](unsigned) (vg_replace_malloc.c:268)
==29696==    by 0x418A046: SlotMemSegment::SlotMemSegment(char const*) (slot.cpp:1452)
==29696==    by 0x418CAF5: Slot::Slot(char const*, Log*, _CKYCardContext*) (slot.cpp:335)
==29696==    by 0x418D241: SlotList::updateSlotList() (slot.cpp:143)
==29696==    by 0x418D439: SlotList::SlotList(Log*) (slot.cpp:74)
==29696==    by 0x41827D7: C_Initialize (coolkey.cpp:239)
==29696==    by 0x403D5CF: secmod_ModuleInit (pk11load.c:164)
==29696==    by 0x403DB97: SECMOD_LoadPKCS11Module (pk11load.c:378)
==29696==    by 0x4050FDA: SECMOD_LoadModule (pk11pars.c:323)
==29696==    by 0x405116E: SECMOD_LoadModule (pk11pars.c:338)
==29696==    by 0x401DBF1: nss_Init (nssinit.c:536)
==29696==    by 0x401E1BC: NSS_Initialize (nssinit.c:653)

Comment 2 Stanislav Brabec 2009-04-14 17:15:34 UTC
Created attachment 339527 [details]
fix for yet another occurrence

Patch for yet another occurrence of this error found by David Binderman:

https://bugzilla.novell.com/show_bug.cgi?id=443369

Comment 3 Kamil Dudka 2009-05-27 15:59:07 UTC
Raising priority to high. This typo-like bug breaks other packages two years for nothing. It's easy to apply two one-line patches like these.

Comment 4 Bug Zapper 2009-06-09 11:16:12 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 11 development cycle.
Changing version to '11'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 5 Kamil Dudka 2009-08-22 18:40:12 UTC
proposing as F12Target

Comment 6 Elio Maldonado Batiz 2009-09-16 04:27:12 UTC
And it would be nice to have this CoolKey fixes in time for the upcoming NSS test day.

Comment 7 Jack Magne 2009-09-16 17:00:13 UTC
Sounds like a good idea.

Comment 8 Stanislav Brabec 2009-09-16 17:15:53 UTC
At least bug 245678, bug 246052, bug 250738, bug 356971 and bug 497758 also contain patches. It would be nice to apply all of them and make new bugfix release.

Comment 9 Jack Magne 2009-09-16 18:41:59 UTC
Bob:

I tried out the patches for this bug. They seem to work fine.


RCS file: /cvs/dirsec/coolkey/src/coolkey/slot.cpp,v
retrieving revision 1.11
diff -C 2 -r1.11 slot.cpp
*** src/coolkey/slot.cpp	19 Feb 2009 02:04:13 -0000	1.11
--- src/coolkey/slot.cpp	16 Sep 2009 18:38:17 -0000

***************
*** 1529,1533 ****
      sprintf(segName,SEGMENT_PREFIX"%s",readerName); 
      segment = SHMem::initSegment(segName, MAX_OBJECT_STORE_SIZE, needInit);
!     delete segName;
      if (!segment) {
  	// just run without shared memory
--- 1529,1533 ----
      sprintf(segName,SEGMENT_PREFIX"%s",readerName); 
      segment = SHMem::initSegment(segName, MAX_OBJECT_STORE_SIZE, needInit);
!     delete [] segName;
      if (!segment) {
  	// just run without shared memory

RCS file: /cvs/dirsec/coolkey/src/coolkey/object.cpp,v
retrieving revision 1.3
diff -C 2 -r1.3 object.cpp
*** src/coolkey/object.cpp	14 Feb 2008 23:48:19 -0000	1.3
--- src/coolkey/object.cpp	16 Sep 2009 18:38:16 -0000
***************
*** 398,402 ****
      // clean up old one
      if (label) {
! 	delete label;
  	label = NULL;
      }
--- 398,402 ----
      // clean up old one
      if (label) {
! 	delete [] label;
  	label = NULL;
      }

Comment 10 Bob Relyea 2009-09-16 21:02:33 UTC
r+ for this patch...

There is one other place that is still missing...
~PKCS11Object in object.h. both the 'delete label' and 'delete name' should be
delete [] label; and delete [] name;

bob

Comment 11 Jack Magne 2009-09-16 23:58:58 UTC
Checking in configure.in;
/cvs/dirsec/coolkey/configure.in,v  <--  configure.in
new revision: 1.15; previous revision: 1.14
done
Running syncmail...
Mailing relnotes@fedoraproject.org...
...syncmail done.
Running syncmail...
Mailing cvsdirsec@fedoraproject.org...
...syncmail done.
Checking in src/coolkey/object.cpp;
/cvs/dirsec/coolkey/src/coolkey/object.cpp,v  <--  object.cpp
new revision: 1.4; previous revision: 1.3
done
Checking in src/coolkey/object.h;
/cvs/dirsec/coolkey/src/coolkey/object.h,v  <--  object.h
new revision: 1.2; previous revision: 1.1
done
Checking in src/coolkey/slot.cpp;
/cvs/dirsec/coolkey/src/coolkey/slot.cpp,v  <--  slot.cpp
new revision: 1.12; previous revision: 1.11
done
Running syncmail...
Mailing relnotes@fedoraproject.org...
...syncmail done.
Running syncmail...
Mailing cvsdirsec@fedoraproject.org...
...syncmail done.

Comment 12 Bug Zapper 2010-04-27 12:56:11 UTC
This message is a reminder that Fedora 11 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 11.  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 '11'.

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 11's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 11 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 please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

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.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 13 Bug Zapper 2010-06-28 11:15:24 UTC
Fedora 11 changed to end-of-life (EOL) status on 2010-06-25. Fedora 11 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.

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

Comment 14 Stanislav Brabec 2010-06-28 17:04:04 UTC
Both issues are already fixed:

http://cvs.fedoraproject.org/viewvc/devel/coolkey/coolkey-simple-bugs.patch?revision=1.1&view=markup


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