From 04f23a200ec31f6dfa6a26e1e35cb152d0246e1b Mon Sep 17 00:00:00 2001 From: Paul Slootman Date: Wed, 6 May 1998 14:43:27 +0000 Subject: [PATCH] Assumption about country codes always being 2 digits long fixed for the USA case (caused strncpy to be called with length -1; ouch). --- isdnlog/tools/tools.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/isdnlog/tools/tools.c b/isdnlog/tools/tools.c index 9d84059d..6e8618b5 100644 --- a/isdnlog/tools/tools.c +++ b/isdnlog/tools/tools.c @@ -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 + * - 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 */