diff --git a/read.c b/read.c index e6f9403..1c14722 100644 --- a/read.c +++ b/read.c @@ -47,8 +47,12 @@ readname_loop(char *packet, char **src, char *dst, size_t length, size_t loop) c--; } + + if (len < length - 1) { + break; /* We used up all space */ + } - if (*s != 0 && len < length - 1) + if (*s != 0) *d++ = '.'; } (*src) = s+1; diff --git a/test.c b/test.c index 640e72c..f882f2f 100644 --- a/test.c +++ b/test.c @@ -146,7 +146,6 @@ test_readname() data = longname + sizeof(HEADER); buf[256] = '\a'; rv = readname(longname, &data, buf, 256); - printf("got %d, '%s' len %d \n", rv, buf, strlen(buf)); assert(buf[256] == '\a'); printf("OK\n");