[gnutls-dev] [PATCH] error handling large CA files
Ian Peters
itp at ximian.com
Wed Mar 12 16:08:01 CET 2003
On Wed, 2003-03-12 at 05:46, Nikos Mavroyanopoulos wrote:
> On Tue, Mar 11, 2003 at 04:41:39PM -0500, Ian Peters wrote:
> It is already solved in the 0.9.0 release, but this has the problem of loading
> the whole file into memory.
>
> I'm now working on something that will allow reading mmaped file regions. That
> will need and strnstr implementation which is not available in gnu libc (thus
> I'll have to implement it or get it from somewhere).
Right; I looked at doing it with mmap, but parse_pem_cert_mem and
similar functions seemed to assume NULL-terminated strings, regardless
of the passed in length -- hence the need for strnstr and some tweaks in
the parsing code.
Anyway, if you're already working on it, I'm not going to worry about it
anymore (and stick with the inefficient solution of reading the entire
file into memory for now). BTW here's a strnstr I used for another
project a while back, pretty straightforward.
#include <string.h>
char *
strnstr (const char *haystack, const char *needle, size_t hlen)
{
size_t nlen;
if (!needle || !*needle)
return (char *)haystack;
else
nlen = strlen (needle);
while (hlen >= nlen) {
if (*needle == *haystack && !strncmp (haystack + 1, needle + 1,
nlen - 1))
return (char *) haystack;
haystack++; hlen--;
}
return NULL;
}
Also, do you have any plans at this point for what your upcoming
releases should be? When do you / will you consider the 0.9.x releases
to be a better choice than the 0.8.x releases?
Ian
More information about the Gnutls-devel
mailing list