Changeset 438
- Timestamp:
- Aug 29, 2013, 8:37:23 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_ignore.c
r425 r438 33 33 #endif 34 34 35 #include <string.h> 36 35 37 #include "samhain.h" 36 38 #include "sh_mem.h" … … 59 61 { 60 62 struct sh_ignore_list * new; 63 char * reg_expr; 64 size_t len; 65 61 66 #ifdef HAVE_REGEX_H 62 67 int status = -1; … … 68 73 SL_ENTER(_("sh_ignore_add")); 69 74 70 if ( addpath == NULL)75 if ( (addpath == NULL) || (sl_ok_adds(2, strlen(addpath)) == SL_FALSE) ) 71 76 { 72 77 SL_RETURN(list, _("sh_ignore_add")); 73 78 } 74 79 75 new = SH_ALLOC(sizeof(struct sh_ignore_list)); 76 77 #ifdef HAVE_REGEX_H 78 status = regcomp(&(new->preg), addpath, REG_NOSUB|REG_EXTENDED); 80 new = SH_ALLOC(sizeof(struct sh_ignore_list)); 81 82 len = 2 + strlen(addpath); 83 reg_expr = SH_ALLOC(len); 84 sl_strlcpy(reg_expr, "^", len); 85 sl_strlcat(reg_expr, addpath, len); 86 87 #ifdef HAVE_REGEX_H 88 status = regcomp(&(new->preg), reg_expr, REG_NOSUB|REG_EXTENDED); 79 89 if (status != 0) 80 90 { … … 83 93 errbuf[BUFSIZ] = '\0'; 84 94 sh_error_handle ((-1), FIL__, __LINE__, status, MSG_E_REGEX, 85 errbuf, addpath);95 errbuf, reg_expr); 86 96 SH_FREE(errbuf); 87 97 SH_FREE(new); 98 SH_FREE(reg_expr); 88 99 SL_RETURN(list, _("sh_ignore_add")); 89 100 } … … 94 105 #endif 95 106 107 SH_FREE(reg_expr); 96 108 new->next = list; 97 109 … … 253 265 CuAssertTrue(tc, S_FALSE == ret); 254 266 267 ret = sh_ignore_chk_del ("/my/var/log/foo/test"); 268 CuAssertTrue(tc, S_FALSE == ret); 269 255 270 sh_ignore_clean(); 256 271 CuAssertTrue(tc, NULL == sh_del_ign); … … 274 289 CuAssertTrue(tc, S_FALSE == ret); 275 290 291 ret = sh_ignore_chk_new ("/my/var/log/foo/test"); 292 CuAssertTrue(tc, S_FALSE == ret); 293 276 294 sh_ignore_clean(); 277 295 CuAssertTrue(tc, NULL == sh_new_ign); … … 295 313 CuAssertTrue(tc, S_FALSE == ret); 296 314 315 ret = sh_ignore_chk_mod ("/my/var/log/foo/test"); 316 CuAssertTrue(tc, S_FALSE == ret); 317 297 318 sh_ignore_clean(); 298 319 CuAssertTrue(tc, NULL == sh_new_ign);
Note:
See TracChangeset
for help on using the changeset viewer.