... | ... |
@@ -1,5 +1,5 @@ |
1 | 1 |
/* |
2 |
- * Copyright (C) 2015 Cisco Systems, Inc. and/or its affiliates. All rights reserved. |
|
2 |
+ * Copyright (C) 2015, 2018 Cisco Systems, Inc. and/or its affiliates. All rights reserved. |
|
3 | 3 |
* Copyright (C) 2007-2009 Sourcefire, Inc. |
4 | 4 |
* |
5 | 5 |
* Authors: Tomasz Kojm |
... | ... |
@@ -37,6 +37,7 @@ |
37 | 37 |
#endif |
38 | 38 |
|
39 | 39 |
#include "libclamav/clamav.h" |
40 |
+#include "libclamav/str.h" |
|
40 | 41 |
|
41 | 42 |
#include "shared/optparser.h" |
42 | 43 |
#include "shared/output.h" |
... | ... |
@@ -1,5 +1,5 @@ |
1 | 1 |
/* |
2 |
- * Copyright (C) 2015 Cisco Systems, Inc. and/or its affiliates. All rights reserved. |
|
2 |
+ * Copyright (C) 2015, 2018 Cisco Systems, Inc. and/or its affiliates. All rights reserved. |
|
3 | 3 |
* Copyright (C) 2015 Sourcefire, Inc. |
4 | 4 |
* |
5 | 5 |
* Authors: Mickey Sola |
... | ... |
@@ -44,6 +44,7 @@ |
44 | 44 |
|
45 | 45 |
#include "libclamav/clamav.h" |
46 | 46 |
#include "libclamav/scanners.h" |
47 |
+#include "libclamav/str.h" |
|
47 | 48 |
|
48 | 49 |
#include "shared/optparser.h" |
49 | 50 |
#include "shared/output.h" |
... | ... |
@@ -438,7 +439,7 @@ static int onas_add_hashnode_child(struct onas_hnode *node, const char* dirname) |
438 | 438 |
if (!child) return CL_EMEM; |
439 | 439 |
|
440 | 440 |
size_t n = strlen(dirname); |
441 |
- child->dirname = strndup(dirname, n); |
|
441 |
+ child->dirname = cli_strndup(dirname, n); |
|
442 | 442 |
|
443 | 443 |
onas_add_listnode(node->childtail, child); |
444 | 444 |
|
... | ... |
@@ -500,7 +501,7 @@ inline static char *onas_get_parent(const char *pathname, size_t len) { |
500 | 500 |
idx++; |
501 | 501 |
} |
502 | 502 |
|
503 |
- ret = strndup(pathname, idx); |
|
503 |
+ ret = cli_strndup(pathname, idx); |
|
504 | 504 |
if (!ret) { |
505 | 505 |
errno = ENOMEM; |
506 | 506 |
return NULL; |
... | ... |
@@ -596,7 +597,7 @@ int onas_ht_add_hierarchy(struct onas_ht *ht, const char *pathname) { |
596 | 596 |
if (!hnode) return CL_EMEM; |
597 | 597 |
|
598 | 598 |
hnode->pathlen = curr->fts_pathlen; |
599 |
- hnode->pathname = strndup(curr->fts_path, hnode->pathlen); |
|
599 |
+ hnode->pathname = cli_strndup(curr->fts_path, hnode->pathlen); |
|
600 | 600 |
|
601 | 601 |
hnode->prnt_pathname = onas_get_parent(hnode->pathname, hnode->pathlen); |
602 | 602 |
if (hnode->prnt_pathname) |
... | ... |
@@ -1,5 +1,5 @@ |
1 | 1 |
/* |
2 |
- * Copyright (C) 2015 Cisco Systems, Inc. and/or its affiliates. All rights reserved. |
|
2 |
+ * Copyright (C) 2015, 2018 Cisco Systems, Inc. and/or its affiliates. All rights reserved. |
|
3 | 3 |
* Copyright (C) 2007-2008 Sourcefire, Inc. |
4 | 4 |
* |
5 | 5 |
* Authors: Tomasz Kojm, Nigel Horne, Török Edvin |
... | ... |
@@ -460,6 +460,38 @@ const char* cli_strcasestr(const char* a, const char *b) |
460 | 460 |
} |
461 | 461 |
#endif |
462 | 462 |
|
463 |
+#ifndef HAVE_STRNLEN |
|
464 |
+size_t cli_strnlen(const char *s, size_t n) |
|
465 |
+{ |
|
466 |
+ size_t i = 0; |
|
467 |
+ for(; (i < n) && s[i] != '\0'; ++i); |
|
468 |
+ return i; |
|
469 |
+} |
|
470 |
+#endif |
|
471 |
+ |
|
472 |
+#ifndef HAVE_STRNDUP |
|
473 |
+char *cli_strndup(const char *s, size_t n) |
|
474 |
+{ |
|
475 |
+ char *alloc; |
|
476 |
+ size_t len; |
|
477 |
+ |
|
478 |
+ if(!s) { |
|
479 |
+ return NULL; |
|
480 |
+ } |
|
481 |
+ |
|
482 |
+ len = strnlen(s, n); |
|
483 |
+ alloc = malloc(len+1); |
|
484 |
+ |
|
485 |
+ if(!alloc) { |
|
486 |
+ return NULL; |
|
487 |
+ } else |
|
488 |
+ memcpy(alloc, s, len); |
|
489 |
+ |
|
490 |
+ alloc[len] = '\0'; |
|
491 |
+ return alloc; |
|
492 |
+} |
|
493 |
+#endif |
|
494 |
+ |
|
463 | 495 |
size_t cli_strtokenize(char *buffer, const char delim, const size_t token_count, const char **tokens) |
464 | 496 |
{ |
465 | 497 |
size_t tokens_found, i; |
... | ... |
@@ -1,5 +1,5 @@ |
1 | 1 |
/* |
2 |
- * Copyright (C) 2015 Cisco Systems, Inc. and/or its affiliates. All rights reserved. |
|
2 |
+ * Copyright (C) 2015, 2018 Cisco Systems, Inc. and/or its affiliates. All rights reserved. |
|
3 | 3 |
* Copyright (C) 2007-2008 Sourcefire, Inc. |
4 | 4 |
* |
5 | 5 |
* Authors: Tomasz Kojm, Nigel Horne, Török Edvin |
... | ... |
@@ -33,6 +33,18 @@ |
33 | 33 |
const char *cli_strcasestr(const char *haystack, const char *needle); |
34 | 34 |
#endif |
35 | 35 |
|
36 |
+#ifdef HAVE_STRNDUP |
|
37 |
+#define cli_strndup strndup |
|
38 |
+#else |
|
39 |
+char *cli_strndup(const char *s, size_t n); |
|
40 |
+#endif |
|
41 |
+ |
|
42 |
+#ifdef HAVE_STRNLEN |
|
43 |
+#define cli_strnlen strnlen |
|
44 |
+#else |
|
45 |
+size_t cli_strnlen(const char *s, size_t n); |
|
46 |
+#endif |
|
47 |
+ |
|
36 | 48 |
#include <stdio.h> |
37 | 49 |
#define cli_nocase(val) tolower(val) |
38 | 50 |
#define cli_nocasei(val) toupper(val) |
... | ... |
@@ -2,7 +2,9 @@ AX_CHECK_UNAME_SYSCALL |
2 | 2 |
AC_CHECK_LIB([socket], [bind], [LIBS="$LIBS -lsocket"; CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lsocket"; FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lsocket"; CLAMD_LIBS="$CLAMD_LIBS -lsocket"]) |
3 | 3 |
AC_SEARCH_LIBS([gethostent],[nsl], [(LIBS="$LIBS -lnsl"; CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lnsl"; FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lnsl"; CLAMD_LIBS="$CLAMD_LIBS -lnsl")]) |
4 | 4 |
|
5 |
-AC_CHECK_FUNCS([poll setsid memcpy snprintf vsnprintf strerror_r strlcpy strlcat strcasestr inet_ntop setgroups initgroups ctime_r mkstemp mallinfo madvise getnameinfo]) |
|
5 |
+AC_CHECK_FUNCS_ONCE([poll setsid memcpy snprintf vsnprintf strerror_r strlcpy strlcat strcasestr inet_ntop setgroups initgroups ctime_r mkstemp mallinfo madvise getnameinfo]) |
|
6 |
+AC_CHECK_FUNCS([strndup]) |
|
7 |
+AC_CHECK_FUNCS([strnlen]) |
|
6 | 8 |
AC_FUNC_FSEEKO |
7 | 9 |
|
8 | 10 |
dnl Check if anon maps are available, check if we can determine the page size |