Changeset 452
- Timestamp:
- Jun 26, 2014, 8:01:54 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile.in
r448 r452 1743 1743 sh_utmp.o: $(srcsrc)/sh_utmp.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_modules.h $(srcinc)/sh_utmp.h $(srcinc)/sh_pthread.h $(srcinc)/sh_inotify.h 1744 1744 sh_kern.o: $(srcsrc)/sh_kern.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_modules.h $(srcinc)/sh_kern.h sh_ks_xor.h $(srcinc)/sh_unix.h $(srcinc)/sh_hash.h 1745 sh_suidchk.o: $(srcsrc)/sh_suidchk.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_modules.h $(srcinc)/sh_suidchk.h $(srcinc)/sh_hash.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_schedule.h $(srcinc)/sh_calls.h 1745 sh_suidchk.o: $(srcsrc)/sh_suidchk.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_modules.h $(srcinc)/sh_suidchk.h $(srcinc)/sh_hash.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_schedule.h $(srcinc)/sh_calls.h $(srcinc)/zAVLTree.h 1746 1746 sh_srp.o: $(srcsrc)/sh_srp.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_tiger.h $(srcinc)/sh_mem.h $(srcinc)/sh_utils.h $(srcinc)/sh_srp.h $(srcinc)/bignum.h $(srcinc)/CuTest.h 1747 1747 sh_fifo.o: $(srcsrc)/sh_fifo.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_mem.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_string.h $(srcinc)/sh_fifo.h -
trunk/depend.dep
r448 r452 21 21 sh_utmp.o: $(srcsrc)/sh_utmp.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_modules.h $(srcinc)/sh_utmp.h $(srcinc)/sh_pthread.h $(srcinc)/sh_inotify.h 22 22 sh_kern.o: $(srcsrc)/sh_kern.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_modules.h $(srcinc)/sh_kern.h sh_ks_xor.h $(srcinc)/sh_unix.h $(srcinc)/sh_hash.h 23 sh_suidchk.o: $(srcsrc)/sh_suidchk.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_modules.h $(srcinc)/sh_suidchk.h $(srcinc)/sh_hash.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_schedule.h $(srcinc)/sh_calls.h 23 sh_suidchk.o: $(srcsrc)/sh_suidchk.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_modules.h $(srcinc)/sh_suidchk.h $(srcinc)/sh_hash.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_schedule.h $(srcinc)/sh_calls.h $(srcinc)/zAVLTree.h 24 24 sh_srp.o: $(srcsrc)/sh_srp.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_tiger.h $(srcinc)/sh_mem.h $(srcinc)/sh_utils.h $(srcinc)/sh_srp.h $(srcinc)/bignum.h $(srcinc)/CuTest.h 25 25 sh_fifo.o: $(srcsrc)/sh_fifo.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_mem.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_string.h $(srcinc)/sh_fifo.h -
trunk/depend.sum
r448 r452 1 3 8610868251 3192621362 -
trunk/include/zAVLTree.h
r363 r452 74 74 extern void *zAVLNext (zAVLCursor *avlcursor); 75 75 76 extern char * zAVL_string_get (zAVLTree * tree, char * key); 77 /* uses strdup to insert a copy */ 78 extern int zAVL_string_set (zAVLTree ** tree, const char * key); 79 extern void zAVL_string_reset (zAVLTree * tree); 80 76 81 #endif -
trunk/src/cutest_zAVLTree.c
r366 r452 37 37 int result; 38 38 int counter = 0; 39 40 char * str; 39 41 40 42 struct ztest z1 = { "abc" , 1 }; … … 483 485 CuAssertTrue (tc, iz8.iname == 0); 484 486 487 ztest_tree = NULL; 488 str = strdup("foo"); 489 result = zAVL_string_set(&ztest_tree, str); 490 CuAssertTrue(tc, 0 == result); 491 CuAssertPtrNotNull(tc, ztest_tree); 492 CuAssertStrEquals(tc, "foo", zAVL_string_get(ztest_tree, "foo")); 493 494 str = strdup("bar"); 495 result = zAVL_string_set(&ztest_tree, str); 496 CuAssertTrue(tc, 0 == result); 497 CuAssertStrEquals(tc, "foo", zAVL_string_get(ztest_tree, "foo")); 498 CuAssertStrEquals(tc, "bar", zAVL_string_get(ztest_tree, "bar")); 499 500 str = strdup("balloon"); 501 result = zAVL_string_set(&ztest_tree, str); 502 CuAssertTrue(tc, 0 == result); 503 CuAssertStrEquals(tc, "foo", zAVL_string_get(ztest_tree, "foo")); 504 CuAssertStrEquals(tc, "bar", zAVL_string_get(ztest_tree, "bar")); 505 CuAssertStrEquals(tc, "balloon", zAVL_string_get(ztest_tree, "balloon")); 506 507 str = zAVL_string_get(ztest_tree, "foobar"); 508 CuAssertTrue(tc, str == NULL); 509 str = zAVL_string_get(ztest_tree, ""); 510 CuAssertTrue(tc, str == NULL); 511 str = zAVL_string_get(ztest_tree, NULL); 512 CuAssertTrue(tc, str == NULL); 513 514 zAVL_string_reset(ztest_tree); 515 str = zAVL_string_get(ztest_tree, "foo"); 516 CuAssertTrue(tc, str == NULL); 517 str = zAVL_string_get(ztest_tree, "bar"); 518 CuAssertTrue(tc, str == NULL); 519 str = zAVL_string_get(ztest_tree, "balloon"); 520 CuAssertTrue(tc, str == NULL); 485 521 486 522 } -
trunk/src/sh_suidchk.c
r440 r452 82 82 #include "sh_schedule.h" 83 83 #include "sh_calls.h" 84 #include "zAVLTree.h" 84 85 85 86 … … 146 147 static int ShSuidchkQDelete = S_FALSE; 147 148 static int ShSuidchkSeverity = SH_ERR_SEVERE; 148 static char * ShSuidchkExclude = NULL;149 static size_t ExcludeLen = 0;150 149 151 150 static time_t FileLimNow = 0; … … 155 154 156 155 static sh_schedule_t * ShSuidchkSched = NULL; 156 157 158 static zAVLTree * ShSuidchkExclude = NULL; 159 static void sh_suid_exclude_free() 160 { 161 zAVL_string_reset(ShSuidchkExclude); 162 ShSuidchkExclude = NULL; 163 return; 164 } 165 static int sh_suid_exclude_add(const char * str) 166 { 167 size_t len; 168 int ret; 169 char * key = sh_util_strdup(str); 170 171 len = sl_strlen (key); 172 if (len && key[len-1] == '/') 173 { 174 key[len-1] = '\0'; 175 } 176 ret = zAVL_string_set(&ShSuidchkExclude, key); 177 SH_FREE(key); 178 return ret; 179 } 180 157 181 158 182 static char * … … 179 203 ShSuidchkSeverity = SH_ERR_SEVERE; 180 204 if (ShSuidchkExclude != NULL) 181 SH_FREE(ShSuidchkExclude); 182 ShSuidchkExclude = NULL; 183 ExcludeLen = 0; 205 sh_suid_exclude_free(ShSuidchkExclude); 184 206 185 207 FileLimNow = 0; … … 1136 1158 if (tlen >= 6 && 0 == strcmp(&tmp[tlen-6], _("/.gvfs"))) 1137 1159 elevel = SH_ERR_NOTICE; 1160 else if (tlen >= 5 && 0 == strcmp(&((mnt->mnt_dir)[tlen-5]), _("/gvfs"))) 1161 elevel = SH_ERR_NOTICE; 1138 1162 1139 1163 /* If we are scanning a temporary directory where dirs and files … … 1156 1180 if (/*@-usedef@*/S_ISDIR(buf.st_mode)/*@+usedef@*/ && 1157 1181 (ShSuidchkExclude == NULL || 1158 0 != strcmp(tmpcat, ShSuidchkExclude)))1182 NULL == zAVL_string_get(ShSuidchkExclude, tmpcat))) 1159 1183 { 1160 1184 /* fs is a STATIC string or NULL … … 1529 1553 int sh_suidchk_set_exclude (const char * c) 1530 1554 { 1555 int ret = 0; 1531 1556 SL_ENTER(_("sh_suidchk_set_exclude")); 1532 1557 … … 1539 1564 { 1540 1565 if (ShSuidchkExclude != NULL) 1541 SH_FREE(ShSuidchkExclude); 1542 ShSuidchkExclude = NULL; 1566 sh_suid_exclude_free(); 1543 1567 SL_RETURN(0, _("sh_suidchk_set_exclude")); 1544 1568 } 1545 1569 1546 if (ShSuidchkExclude != NULL) 1547 SH_FREE(ShSuidchkExclude); 1548 1549 ShSuidchkExclude = sh_util_strdup (c); 1550 ExcludeLen = sl_strlen (ShSuidchkExclude); 1551 if (ShSuidchkExclude && ShSuidchkExclude[ExcludeLen-1] == '/') 1552 { 1553 ShSuidchkExclude[ExcludeLen-1] = '\0'; 1554 ExcludeLen--; 1555 } 1556 SL_RETURN(0, _("sh_suidchk_set_exclude")); 1570 ret = sh_suid_exclude_add(c); 1571 1572 SL_RETURN(ret, _("sh_suidchk_set_exclude")); 1557 1573 } 1558 1574 -
trunk/src/zAVLTree.c
r383 r452 33 33 #include "zAVLTree.h" 34 34 35 /* Interface for handling "string only" items rw 2014-06-26 36 */ 37 static zAVLKey zstring_key (void const * arg) 38 { 39 return (zAVLKey) arg; 40 } 41 static void zfree_string (void * inptr) 42 { 43 char * str = (char *) inptr; 44 str[0] = '\0'; 45 free (str); 46 return; 47 } 48 void zAVL_string_reset (zAVLTree * tree) 49 { 50 if (tree) 51 zAVLFreeTree (tree, zfree_string); 52 return; 53 } 54 int zAVL_string_set (zAVLTree ** tree, const char * key) 55 { 56 if (tree && key) 57 { 58 zAVLTree * itree = (*tree); 59 if (!itree) 60 { 61 itree = zAVLAllocTree (zstring_key, zAVL_KEY_STRING); 62 if (!itree) 63 { 64 return -1; 65 } 66 } 67 *tree = itree; 68 return zAVLInsert (itree, strdup(key)); 69 } 70 return -1; 71 } 72 char * zAVL_string_get (zAVLTree * tree, char * key) 73 { 74 /* zAVLSearch() checks for NULL tree 75 */ 76 if (key) 77 { 78 return ((char *) zAVLSearch (tree, key)); 79 } 80 return NULL; 81 } 82 83 35 84 /* Wed Nov 23 17:57:42 CET 2005 rw: introduce third argument in 36 85 * zAVLCloseSearchNode() to avoid redundant strcmp … … 86 135 zAVLTree *rc; 87 136 88 rc = malloc(sizeof(zAVLTree));137 rc = calloc(1, sizeof(zAVLTree)); 89 138 if (rc == NULL) 90 139 return NULL; … … 130 179 int ok; 131 180 132 newnode = malloc(sizeof(zAVLNode));181 newnode = calloc(1, sizeof(zAVLNode)); 133 182 if (newnode == NULL) 134 183 return -1;
Note:
See TracChangeset
for help on using the changeset viewer.