diff --git a/tools/parser/sdp.c b/tools/parser/sdp.c
index 3f0d120..73b62ca 100644
--- a/tools/parser/sdp.c
+++ b/tools/parser/sdp.c
#include <stdio.h>
#include <errno.h>
+#include <ctype.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
static inline void print_string(int n, struct frame *frm, const char *name)
{
- char *s;
+ int i, hex = 0;
+
+ for (i = 0; i < n; i++)
+ if (!isprint(((char *) frm->ptr)[i])) {
+ hex = 1;
+ break;
+ }
printf(" %s", name);
- if ((s = malloc(n + 1))) {
- strncpy(s, frm->ptr, n);
- s[n] = '\0';
- printf(" \"%s\"", s);
- free(s);
- } else
- perror("Can't allocate string buffer");
+ if (hex) {
+ for (i = 0; i < n; i++)
+ printf(" %02x", ((unsigned char *) frm->ptr)[i]);
+ } else {
+ printf(" \"");
+ for (i = 0; i < n; i++)
+ printf("%c", ((char *) frm->ptr)[i]);
+ printf("\"");
+ }
frm->ptr += n;
frm->len -= n;