Thread (2 messages) flat view 2 messages, 2 authors, 2016-08-05

Re: [PATCH 2/2] nedmalloc: work around overzealous GCC 6 warning

From: Jeff King <hidden>
Date: 2016-08-05 07:42:51

Possibly related (same subject, not in this thread)

On Thu, Aug 04, 2016 at 11:24:32PM -0700, Junio C Hamano wrote:
I do not know if we want to worry about st_add(1, strlen(s1))
overflow around here, though.
[...]
+	size_t len = strlen(s1) + 1;
I wondered that, too, but I don't think it's possible.

To overflow the size_t with "+1", strlen() must return the maximum value
that it can hold. But such a string would need one more byte than that,
for its trailing NUL. So assuming you cannot have a string that exceeds
size_t in the first place, I think it is impossible to overflow here.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help