Messages in this thread | | | Date | Mon, 18 Aug 2003 12:40:37 -0400 | From | Timothy Miller <> | Subject | Re: generic strncpy - off-by-one error |
| |
Daniel Forrest wrote:
> > - if (count) { > + if (count >= sizeof(long)) { > size_t count2; >
I like this size check here, but the comparison should be to some number greater than sizeof(long). There is a threshold below which it's not worth it to do all of the extra loops. If you're going to fill only four bytes, it's probably best to do it just using the last loop.
Maybe through some trial and error, we could determine what that threshold is. I'm betting it's something around 2* or 3* word size.
[snip]
> + > + while (count) { > + *tmp++ = '\0'; > + count--; > } > > return dest; > } >
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |