Assumption about country codes always being 2 digits long fixed for the
USA case (caused strncpy to be called with length -1; ouch).
This commit is contained in:
parent
0c590a08dd
commit
c3db75d0d7
|
@ -1,4 +1,4 @@
|
|||
/* $Id: tools.c,v 1.10 1998/04/09 19:15:45 akool Exp $
|
||||
/* $Id: tools.c,v 1.11 1998/05/06 14:43:27 paul Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux. (Utilities)
|
||||
*
|
||||
|
@ -19,6 +19,10 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: tools.c,v $
|
||||
* Revision 1.11 1998/05/06 14:43:27 paul
|
||||
* Assumption about country codes always being 2 digits long fixed for the
|
||||
* USA case (caused strncpy to be called with length -1; ouch).
|
||||
*
|
||||
* Revision 1.10 1998/04/09 19:15:45 akool
|
||||
* - CityPlus Implementation from Oliver Lauer <Oliver.Lauer@coburg.baynet.de>
|
||||
* - dont change huptimeout, if disabled (via isdnctrl huptimeout isdnX 0)
|
||||
|
@ -408,6 +412,7 @@ char *vnum(int chan, int who)
|
|||
auto char *ptr;
|
||||
auto int ll;
|
||||
auto int prefix = strlen(countryprefix);
|
||||
auto int cc_len = 2; /* country code length defaults to 2 */
|
||||
|
||||
|
||||
if (++retnum == MAXRET)
|
||||
|
@ -442,12 +447,15 @@ char *vnum(int chan, int who)
|
|||
got++;
|
||||
} /* if */
|
||||
|
||||
/* Die folgenden Zeilen basieren nur auf eine Annahme, das ein Laendercode
|
||||
aus zwei Ziffern besteht!!!!!!! */
|
||||
|
||||
if (l > 1) {
|
||||
strncpy(call[chan].areacode[who], call[chan].num[who], 2 + prefix);
|
||||
strncpy(call[chan].vorwahl[who], call[chan].num[who] + 2 + prefix, l - 2 - prefix);
|
||||
if (call[chan].num[who][prefix] == '1')
|
||||
cc_len = 1; /* USA is only country with country code length 1 */
|
||||
/*
|
||||
* there should be code for country codes > 2 in length,
|
||||
* but that at least doesn't cause a possible strncpy(x, y, -1) call!
|
||||
*/
|
||||
strncpy(call[chan].areacode[who], call[chan].num[who], cc_len + prefix);
|
||||
strncpy(call[chan].vorwahl[who], call[chan].num[who] + cc_len + prefix, l - cc_len - prefix);
|
||||
strcpy(call[chan].rufnummer[who], call[chan].num[who] + l);
|
||||
} /* if */
|
||||
|
||||
|
|
Loading…
Reference in New Issue