diff options
author | Bill Nottingham <notting@redhat.com> | 2003-09-04 01:30:26 +0000 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 2003-09-04 01:30:26 +0000 |
commit | c222a1c2a46c42c12b5d898091962122375c9c42 (patch) | |
tree | 86eab9c8646f47cdbd3d28e062527cb0923ef0b2 | |
parent | 6c775c89dbb3666ccf7fe1eb82ef9ff17f16904a (diff) | |
download | initscripts-c222a1c2a46c42c12b5d898091962122375c9c42.tar initscripts-c222a1c2a46c42c12b5d898091962122375c9c42.tar.gz initscripts-c222a1c2a46c42c12b5d898091962122375c9c42.tar.bz2 initscripts-c222a1c2a46c42c12b5d898091962122375c9c42.tar.xz initscripts-c222a1c2a46c42c12b5d898091962122375c9c42.zip |
fix some memory handling (#85478, <miked@ed.ac.uk>)initscripts-7_3-branch
-rw-r--r-- | src/ipcalc.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/ipcalc.c b/src/ipcalc.c index d981be83..468a037c 100644 --- a/src/ipcalc.c +++ b/src/ipcalc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2001 Red Hat, Inc. All rights reserved. + * Copyright (c) 1997-2003 Red Hat, Inc. All rights reserved. * * This software may be freely redistributed under the terms of the GNU * public license. @@ -70,7 +70,7 @@ \return a network mask, in network byte order. */ unsigned long int prefix2mask(int prefix) { - return htonl(~((2 << (31 - prefix)) - 1)); + return htonl(~((1 << (32 - prefix)) - 1)); } /*! @@ -296,7 +296,7 @@ int main(int argc, const char **argv) { } tmp = NULL; for (; i>0; i--) { - tmp = malloc(strlen(ipStr + 3)); + tmp = malloc(strlen(ipStr) + 3); sprintf(tmp,"%s.0",ipStr); ipStr = tmp; } @@ -308,13 +308,14 @@ int main(int argc, const char **argv) { return 1; } - poptFreeContext(optCon); if (!(showNetmask|showPrefix|showBroadcast|showNetwork|showHostname)) { poptPrintHelp(optCon, stderr, 0); return 1; } + poptFreeContext(optCon); + /* we know what we want to display now, so display it. */ if (showNetmask) { |