From c3db75d0d7afcc0e8ff6ac0192a43885fd0b0111 Mon Sep 17 00:00:00 2001 From: paul 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 | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/isdnlog/tools/tools.c b/isdnlog/tools/tools.c index e93b8a22..0b533257 100644 --- a/isdnlog/tools/tools.c +++ b/isdnlog/tools/tools.c @@ -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 * - 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 */