--- OLD/daemon.c Thu Jan 1 00:00:00 1970 +++ NEW/daemon.c Thu Jan 1 00:00:00 1970 @@ -533,6 +533,62 @@ } } +static void printableize(const void *data, int len, int *plen, char *pbuf) +{ + const unsigned char *dp; + unsigned char c; + unsigned char tbuf[5]; + int tlen; + int rlen; + + rlen = 0; + for (dp=data;len>0;dp++,len--) + { c = *dp; + switch (c) + { case 7: tbuf[1] = 'a'; if (0) { + case 8: tbuf[1] = 'b'; } if (0) { + case 27: tbuf[1] = 'e'; } if (0) { + case 12: tbuf[1] = 'f'; } if (0) { + case 10: tbuf[1] = 'n'; } if (0) { + case 13: tbuf[1] = 'r'; } if (0) { + case 9: tbuf[1] = 't'; } if (0) { + case 92: tbuf[1] = '\\'; } + tbuf[0] = '\\'; + tlen = 2; + break; + default: + if ((c < 32) || ((c > 126) && (c < 160))) + { tbuf[0] = '\\'; + if ( (c > 077) || + ((len > 1) && (dp[1] >= '0') && (dp[1] <= '9')) ) + { tbuf[1] = (c >> 6) + '0'; + tbuf[2] = ((c >> 3) & 7) + '0'; + tbuf[3] = (c & 7) + '0'; + tlen = 4; + } + else if (c > 7) + { tbuf[1] = ((c >> 3) & 7) + '0'; + tbuf[2] = (c & 7) + '0'; + tlen = 3; + } + else + { tbuf[1] = (c & 7) + '0'; + tlen = 2; + } + } + else + { tlen = 1; + } + break; + } + if (pbuf) + { bcopy((tlen==1)?dp:&tbuf[0],pbuf,tlen); + pbuf += tlen; + } + rlen += tlen; + } + *plen = rlen; +} static int execute(struct sockaddr *addr) { @@ -571,10 +627,24 @@ alarm(0); len = strlen(line); - if (pktlen != len) - loginfo("Extended attributes (%d bytes) exist <%.*s>", - (int) pktlen - len, - (int) pktlen - len, line + len + 1); + if (pktlen > len) + { char *tmp; + int tlen; + printableize(line+len+1,pktlen-len,&tlen,0); + tmp = xmalloc(tlen); + if (tmp) + { printableize(line+len+1,pktlen-len,&tlen,tmp); + loginfo("Extended attributes (%d bytes): <%.*s>", + pktlen-len, tlen, tmp); + free(tmp); + } + else + { loginfo("Extended attributes (%d bytes) - malloc failed",pktlen-len); + } + } + else if (pktlen != len) + { loginfo("Negative extended attributes (pktlen %d, len %d)",pktlen,len); + } if (len && line[len-1] == '\n') { line[--len] = 0; pktlen--;