https://issues.apache.org/bugzilla/show_bug.cgi?id=55696

--- Comment #11 from Konstantin Kolinko <knst.koli...@gmail.com> ---
(In reply to Christopher Schultz from comment #10)

Looks good.

Some style comments
1. Beware tabs. This line is formatted oddly because it has a tab character:
> +         lastchar = buf + len - 1;

2. 
> +        int multit = 1;

Can be moved several lines below into the if(len) block.

Or definition of "char buf[100];" could be moved up just below that line. (see
below).

3.
> +            strncpy(buf, rc, 100);

s/100/sizeof(buf)/ ?

4. strncpy is not a safe function. It the string is longer than 100 characters
it will truncate it without setting a 0 byte at the end.

Thus in other places it is actually strncpy(..., size-1), and it needs some
code to explicitly set the size'th byte of the buffer to 0.

Moreover, you are not recalculating "len" after copying thus if len > 100, the
lastchar pointer will point to some place outside the buffer:

> +         lastchar = buf + len - 1;

Thus maybe s/ if(len) / if (len && len < sizeof(buf)-1) / to resort to the
defaults in this case.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to