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:
Paul Slootman 1998-05-06 14:43:27 +00:00
parent e931b593ca
commit 04f23a200e
1 changed files with 14 additions and 5 deletions

View File

@ -19,6 +19,11 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log$
* 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)
* - Support for more Providers (TelePassport, Tele 2, TelDaFax)
*
* Revision 1.9 1998/03/08 11:43:16 luethje
* I4L-Meeting Wuerzburg final Edition, golden code - Service Pack number One
*
@ -403,6 +408,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)
@ -437,12 +443,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 */