Bug 85478 - ipcalc memory handling: corrupt help text in certain circumstances
Summary: ipcalc memory handling: corrupt help text in certain circumstances
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: initscripts (Show other bugs)
(Show other bugs)
Version: 8.0
Hardware: i386 Linux
low
low
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact: Brock Organ
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-03-03 16:38 UTC by miked
Modified: 2014-03-17 02:34 UTC (History)
1 user (show)

Fixed In Version: 7.31-1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-09-04 01:39:47 UTC
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 16:40 UTC, miked
no flags Details | Diff
allocate enough memory for string (271 bytes, patch)
2003-03-03 16:44 UTC, miked
no flags Details | Diff

Description miked 2003-03-03 16:38:43 UTC
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 16:40:55 UTC
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 16:44:20 UTC
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 16:49:01 UTC
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-04 01:39:47 UTC
Fixed in 7.31-1; thanks!


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