1. ripencc
  2. bgpdump
  3. Issues
Issue #12 resolved

Binary garbage at the end of output

rprior
created an issue

On version 1.4.99.13, bgpdump -m outputs binary garbage at the end for some MRT files, corrupting the last (few) line(s). I have tried it on two different distributions (RHEL 6.0 and Mandriva 2010.2), on two different machines (one Intel, the other AMD), both x86_64. Some of the MRT files where it fails are: rrc00/2001.06/bview.20010624.1611.gz rrc00/2001.06/bview.20010628.0017.gz rrc00/2001.06/updates.20010613.0001.gz rrc00/2001.06/updates.20010613.0316.gz

Comments (2)

  1. Anton Yuzhaninov

    I met with similar problem. On some files bgpdump -m output looks like

    TABLE_DUMPПу©©0/13ХВ (е⌠(<
     (+(34.38|
    

    After N hours of debugging, I have found source of problem - setbuffer().

    There is two ways to fix this bug.

    Declare buffer as static:

    --- a/bgpdump.c Thu Feb 03 15:02:54 2011 +0100
    +++ b/bgpdump.c Mon Feb 11 20:58:50 2013 +0400
    @@ -165,7 +165,7 @@
         }
    
         // more efficient then line buffering
    -    char buffer[16000];
    +    static char buffer[16000];
         setbuffer(stdout, buffer, sizeof buffer);
    
         BGPDUMP *my_dump = bgpdump_open_dump(argv[0]);
    

    Don't use setbuffer() at all.

    --- a/bgpdump.c Thu Feb 03 15:02:54 2011 +0100
    +++ b/bgpdump.c Mon Feb 11 21:00:11 2013 +0400
    @@ -164,10 +164,6 @@
             exit(1);
         }
    
    -    // more efficient then line buffering
    -    char buffer[16000];
    -    setbuffer(stdout, buffer, sizeof buffer);
    -
         BGPDUMP *my_dump = bgpdump_open_dump(argv[0]);
         if(! my_dump)
             return 1;
    

    I prefer second variant, because it allows to set any buffer size via stdbuf command. E. g. stdbuf -o 128k bgpdump -m file for 128k buffer.

  2. Log in to comment