bc uses uninitialized memory

Bug #1259656 reported by Kees Cook
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bc (Debian)
Fix Released
bc (Ubuntu)
Fix Released
Fix Released

Bug Description

This is http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=608255 fixed in later package versions:

bc depends on uninitialized mem:

echo "e(1)" | MALLOC_PERTURB_=1 bc -l
echo "e(1)" | MALLOC_PERTURB_=0 bc -l

This fixes it:

--- storage.c.orig 2010-12-21 19:43:14.663540110 +0000
+++ storage.c 2010-12-21 19:42:01.392540111 +0000
@@ -99,6 +99,7 @@
       f = &functions[indx];
       f->f_defined = FALSE;
+ f->f_void = FALSE;
       f->f_body = (char *) bc_malloc (BC_START_SIZE);
       f->f_body_size = BC_START_SIZE;
       f->f_code_size = 0;

"bc" mathlib routines fail when running under the MALLOC_PERTURB_ environment used by some paranoid people.

The command 'echo "e(1)" | MALLOC_PERTURB_=1 bc -l' should return '2.71828182845904523536' instead of nothing.

Extremely low -- this fix is included in later package versions and fixes the problem.

Kees Cook (kees)
no longer affects: bc
Changed in bc (Ubuntu):
status: New → Fix Released
Changed in bc (Debian):
status: Unknown → Fix Released
Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello Kees, or anyone else affected,

Accepted bc into precise-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/bc/1.06.95-2ubuntu1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in bc (Ubuntu Precise):
status: New → Fix Committed
tags: added: verification-needed
Revision history for this message
Kees Cook (kees) wrote :

This worked for me when installing from -proposed. Thanks!

tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package bc - 1.06.95-2ubuntu1

bc (1.06.95-2ubuntu1) precise-proposed; urgency=low

  * bc/storage.c: initialize memory correctly (LP: #1259656, Closes: 608255),
    thanks to Pádraig Brady.
 -- Kees Cook <email address hidden> Tue, 10 Dec 2013 11:25:33 -0800

Changed in bc (Ubuntu Precise):
status: Fix Committed → Fix Released
Revision history for this message
Colin Watson (cjwatson) wrote : Update Released

The verification of the Stable Release Update for bc has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regresssions.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.