Author: rhs Date: Sat Apr 28 21:03:00 2012 New Revision: 1331830 URL: http://svn.apache.org/viewvc?rev=1331830&view=rev Log: fixed off by one error in pn_quote_data
Modified: qpid/proton/trunk/proton-c/src/util.c Modified: qpid/proton/trunk/proton-c/src/util.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/util.c?rev=1331830&r1=1331829&r2=1331830&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/src/util.c (original) +++ qpid/proton/trunk/proton-c/src/util.c Sat Apr 28 21:03:00 2012 @@ -43,7 +43,7 @@ ssize_t pn_quote_data(char *dst, size_t return PN_OVERFLOW; } } else { - if (idx < capacity - 5) { + if (idx < capacity - 4) { sprintf(dst + idx, "\\x%.2x", c); idx += 4; } else { @@ -60,8 +60,12 @@ void pn_fprint_data(FILE *stream, const { size_t capacity = 4*size + 1; char buf[capacity]; - pn_quote_data(buf, capacity, bytes, size); - fputs(buf, stream); + ssize_t n = pn_quote_data(buf, capacity, bytes, size); + if (n >= 0) { + fputs(buf, stream); + } else { + fprintf(stderr, "pn_quote_data: %zi\n", n); + } } void pn_print_data(const char *bytes, size_t size) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org