On Sat, Dec 19, 2009 at 01:06:02PM +0000, Stuart Henderson wrote:
> On 2009-12-17, Denis Doroshenko <denis.doroshe...@gmail.com> wrote:
> > RFC2865 WRT Class field content says the following:
> >
> >       The String field is one or more octets.
> 
> So the RD_STRING is correct,
> 
> >       string    1-253 octets containing binary data (values 0 through
> >                 255 decimal, inclusive).  Strings of length zero (0)
> >                 MUST NOT be sent; omit the entire attribute instead.
> 
> and the same problem could occur with other strings. How about running
> them through strvisx() instead?
> 

I had the same idea. So I like this idea.

> Index: print-radius.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/tcpdump/print-radius.c,v
> retrieving revision 1.8
> diff -u -p -r1.8 print-radius.c
> --- print-radius.c    23 May 2006 21:57:15 -0000      1.8
> +++ print-radius.c    19 Dec 2009 13:04:46 -0000
> @@ -32,7 +32,9 @@
>  #include <arpa/inet.h>
>  
>  #include <stdio.h>
> +#include <stdlib.h>
>  #include <string.h>
> +#include <vis.h>
>  
>  /* RADIUS support for tcpdump, Thomas Ptacek <t...@enteract.com> */
>  
> @@ -206,6 +208,7 @@ static void r_print_address(int code, in
>  
>  static void r_print_string(int code, int len, const u_char *data) {
>       char string[128];
> +     char vis[128*4];
>  
>       if(!len) {
>               fputs(" ?", stdout);
> @@ -218,7 +221,8 @@ static void r_print_string(int code, int
>       memset(string, 0, 128);
>       memcpy(string, data, len);
>  
> -     fprintf(stdout, " %s", string);
> +     strvisx(vis, string, len, 0);
> +     fprintf(stdout, " %s", vis);

I think this can be simplified further. The memset() and memcpy() can be
skipped since you can call strvisx() directly with data.

>  }
>  
>  static void r_print_hex(int code, int len, const u_char *data) {
> 

-- 
:wq Claudio

Reply via email to