diff --git a/TODO b/TODO index d166f19..c56fcea 100644 --- a/TODO +++ b/TODO @@ -25,6 +25,10 @@ Symmetric decrypt mode tries to open vault pcp_find_primary_secret() makes a copy ??? +sym encrypt mac => mac, mac => freebsd and freebsd => mac doesnt work + +c++ destructor double free mess + Python binding, e.g.: py % cdll.LoadLibrary("libsodium.so.8") diff --git a/configure.ac b/configure.ac index 1fbc169..382d148 100755 --- a/configure.ac +++ b/configure.ac @@ -76,6 +76,7 @@ AC_CHECK_FUNCS( \ memcpy \ perror \ strnlen \ + strnstr \ strlen \ strtol \ sizeof \ diff --git a/include/pcp/config.h.in b/include/pcp/config.h.in index 0dd45ca..6a08a31 100644 --- a/include/pcp/config.h.in +++ b/include/pcp/config.h.in @@ -118,6 +118,9 @@ /* Define to 1 if you have the `strnlen' function. */ #undef HAVE_STRNLEN +/* Define to 1 if you have the `strnstr' function. */ +#undef HAVE_STRNSTR + /* Define to 1 if you have the `strtol' function. */ #undef HAVE_STRTOL diff --git a/include/pcp/platform.h b/include/pcp/platform.h index 7b6e357..46c1295 100644 --- a/include/pcp/platform.h +++ b/include/pcp/platform.h @@ -157,5 +157,33 @@ strnlen(const char *msg, size_t maxlen) } #endif + +#ifndef HAVE_STRNSTR +/* via FreeBSD libc */ +#include +static inline char * +strnstr(const char *s, const char *find, size_t slen) +{ + char c, sc; + size_t len; + + if ((c = *find++) != '\0') { + len = strlen(find); + do { + do { + if (slen-- < 1 || (sc = *s++) == '\0') + return (NULL); + } while (sc != c); + if (len > slen) + return (NULL); + } while (strncmp(s, find, len) != 0); + s--; + } + return ((char *)s); +} +#endif + + #endif /* !_HAVE_PCP_PLATFORM_H */ +