X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Frmr%2Fcommon%2Fsrc%2Frt_generic_static.c;h=253e7ab1c9ccda33f025bb9948b2cb4199f8f097;hb=b7a31bd94da349e9c49f6dd7a5bcded74877a8ae;hp=7add33ca721a9bf9d5416e431fdd72cb2b7764db;hpb=68d09fa5028e47e763c44c30647da31e77eda64a;p=ric-plt%2Flib%2Frmr.git diff --git a/src/rmr/common/src/rt_generic_static.c b/src/rmr/common/src/rt_generic_static.c index 7add33c..253e7ab 100644 --- a/src/rmr/common/src/rt_generic_static.c +++ b/src/rmr/common/src/rt_generic_static.c @@ -489,22 +489,33 @@ static void read_static_rt( uta_ctx_t* ctx, int vlevel ) { return; } - if( (fbuf = uta_fib( fname ) ) == NULL ) { // read file into a single buffer - fprintf( stderr, "[WRN] seed route table could not be opened: %s: %s\n", fname, strerror( errno ) ); + if( (fbuf = uta_fib( fname ) ) == NULL ) { // read file into a single buffer (nil terminated string) + fprintf( stderr, "[WRN] rmr read_static: seed route table could not be opened: %s: %s\n", fname, strerror( errno ) ); return; } - if( DEBUG ) fprintf( stderr, "[INFO] seed route table successfully opened: %s\n", fname ); + if( DEBUG ) fprintf( stderr, "[DBUG] rmr: seed route table successfully opened: %s\n", fname ); + for( eor = fbuf; *eor; eor++ ) { // fix broken systems that use \r or \r\n to terminate records + if( *eor == '\r' ) { + *eor = '\n'; // will look like a blank line which is ok + } + } + for( rec = fbuf; rec && *rec; rec = eor+1 ) { rcount++; if( (eor = strchr( rec, '\n' )) != NULL ) { *eor = 0; + } else { + fprintf( stderr, "[WARN] rmr read_static: seed route table had malformed records (missing newline): %s\n", fname ); + fprintf( stderr, "[WARN] rmr read_static: seed route table not used%s\n", fname ); + free( fbuf ); + return; } parse_rt_rec( ctx, rec, vlevel ); } - if( DEBUG ) fprintf( stderr, "[INFO] seed route table successfully parsed: %d records\n", rcount ); + if( DEBUG ) fprintf( stderr, "[DBUG] rmr: seed route table successfully parsed: %d records\n", rcount ); free( fbuf ); }