Bug 85478 - ipcalc memory handling: corrupt help text in certain circumstances
ipcalc memory handling: corrupt help text in certain circumstances
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: initscripts (Show other bugs)
8.0
i386 Linux
low Severity low
: ---
: ---
Assigned To: Bill Nottingham
Brock Organ
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-03-03 11:38 EST by miked
Modified: 2014-03-16 22:34 EDT (History)
1 user (show)

See Also:
Fixed In Version: 7.31-1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-09-03 21:39:47 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Patch: Free popt memory only after having given out helptext (427 bytes, patch)
2003-03-03 11:40 EST, miked
no flags Details | Diff
allocate enough memory for string (271 bytes, patch)
2003-03-03 11:44 EST, miked
no flags Details | Diff

  None (edit)
Description miked 2003-03-03 11:38:43 EST
ipcalc help text becomes corrupt when given a CIDR style network specification
with no options.  This appears to be related to one or two memory handling
errors inside the program.  Proposed fix information at the end.  

How reproducible:
100% across 

Steps to reproduce:
ipcalc 1.1/23

    
Actual results:
Usage: `áB`áBháBháBÀÀxáBxáBáBáááBáBáBáBáB áB
áB¨áB¨áB°áB°áB¸áB¸áBÀáBÀáBÈáBÈáBÐáBÐáBØáBØáBàáBàáBèáBèáBðáBðáBøáBøáB [OPTION...]
  -b, --broadcast     Display calculated broadcast address
  -h, --hostname      Show hostname determined via DNS
  -m, --netmask       Display default netmask for IP (class A, B, or C)
  -n, --network       Display network address
  -p, --prefix        Display network prefix
  -s, --silent        Don't ever display error messages 

Help options:
  -?, --help          Show this help message
  --usage             Display brief usage message

Expected results:
Usage: ipcalc [OPTION...]
  -b, --broadcast     Display calculated broadcast address
  -h, --hostname      Show hostname determined via DNS
  -m, --netmask       Display default netmask for IP (class A, B, or C)
  -n, --network       Display network address
  -p, --prefix        Display network prefix
  -s, --silent        Don't ever display error messages 

Help options:
  -?, --help          Show this help message
  --usage             Display brief usage message

Additional info:
there are two patches attached to this.  One of them fixes the bug and the other
one is for a separate memory management mistake.  I am not sure if they interact.  

Patch 1: popt memory should not be freed before giving help text (fixes problem)
Patch 2: a round close bracket ')' has been misplaced causing too small memory
allocation (couldn't see any change from this)
Comment 1 miked 2003-03-03 11:40:55 EST
Created attachment 90453 [details]
Patch: Free popt memory only after having given out helptext

N.B. Both patch 1 and patch 2 from this bug report should be applied.
Comment 2 miked 2003-03-03 11:44:20 EST
Created attachment 90454 [details]
allocate enough memory for string

When we allocate the memory for the ip address string, we want to allocate for
the string + the two characters + terminating zero rather than allocating
memory for the remainder of the string starting from three characters in.
Comment 3 miked 2003-03-03 11:49:01 EST
This bug also exists in RedHat 7.3.  The symptom doesn't exist in RedHat 7.1
which didn't provide a help text in this case.  I don't know if that means that
the software is okay.  
Comment 4 Bill Nottingham 2003-09-03 21:39:47 EDT
Fixed in 7.31-1; thanks!

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