# 1. Добавил проверку наличия в конфиге ключевых слов "RouteBegin" # и "RouteEnd". Без них сафроутер таки работает, но делает весьма # странные вещи :) # 2. Сделал так, что бы строка "RouteEnd" не заменялась той, что # прописана в ключевом слове "RouteEnd" (это шаблон а не строка), # а оставалась такой, какой она была в оригинальном файле роутинга. # --- route.cpp-1 2007-02-03 23:46:58.000000000 +0200 +++ route.cpp 2007-02-04 02:04:02.000000000 +0200 @@ -289,9 +289,12 @@ local const char * ErrMissMainAddr = EOLCHR"Missing or illegal main address."; local const char * ErrMissRouteType = EOLCHR"Missing \"RouteType\" keyword."; local const char * ErrMissWriteTo = EOLCHR"Missing \"WriteTo\" keyword."; +local const char * ErrMissRouteBegin = EOLCHR"Missing \"RouteBegin\" keyword."; +local const char * ErrMissRouteEnd = EOLCHR"Missing \"RouteEnd\" keyword."; local const char * ErrMissMinType = EOLCHR"Missing \"Minimize\" keyword. YES Accepted."; local const char * ErrNoReplEnd = EOLCHR"Missing \"RouteEnd\" in dest file."; local const char * ErrNoReplBeg = EOLCHR"Missing \"RouteBegin\" in dest file."; +local const char * ErrReplEndTooLong = EOLCHR"\"RouteEnd\" string is too long in dest file ("; local const char * ErrBadNdlType = "Bad \"HubRoute\" definition."; local const char * ErrMissDirect = EOLCHR"%s is routed via us, but missing in \"Link\" definitions."EOLCHR" \'DefaultFlavor\' assumed."; local const char * ErrReroute = EOLCHR"Re-routing for %s."; @@ -1872,8 +1875,16 @@ if (strncmp(Buff, RouteBegin, beglen) == 0) ReplaceArea = true; - if (ReplaceArea && (strncmp(Buff, RouteEnd, endlen) == 0)) + if (ReplaceArea && (strncmp(Buff, RouteEnd, endlen) == 0)) { + if (strlen (Buff) > (sizeof (RouteEnd) - 1)) { + Error (ErrReplEndTooLong); + ErrorS ("%d > ", strlen (Buff)); + ErrorS ("%d)." , sizeof (RouteEnd) - 1); + return false; + } + strcpy (RouteEnd, Buff); return true; + } } Error(ReplaceArea ? ErrNoReplEnd : ErrNoReplBeg); fclose(OldRoute); @@ -2335,6 +2346,18 @@ Error(ErrMissMainAddr); return false; } + // Existing RouteBegin keyword + if (RouteBegin [0] == '\0') + { + Error(ErrMissRouteBegin); + return false; + } + // Existing RouteEnd keyword + if (RouteEnd [0] == '\0') + { + Error(ErrMissRouteEnd); + return false; + } // Existing RouteType keyword if (!RouteMode) { @@ -2497,7 +2520,7 @@ PutRoutingHpt(); break; } PutUnRouted(); - Spit(RouteEnd); + fputs(RouteEnd, NewRoute); while (fgets(Buff, BUFFLEN-1, OldRoute)) fputs(Buff, NewRoute); fclose(OldRoute);