Changes in trunk/src/sh_prelude.c [20:26]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_prelude.c
r20 r26 133 133 } 134 134 135 static int set_prelude_severity_int (char * str, int prelude_sev) 136 { 137 char * p = strtok (str, ", \t"); 138 135 static int set_prelude_severity_int (const char * str, int prelude_sev) 136 { 137 char * p; 138 char * dup = strdup (str); 139 140 if (!dup) 141 return -1; 142 143 p = strtok (dup, ", \t"); 139 144 if (p) { 140 145 do { … … 155 160 else if (0 == strcmp (p, _("info"))) 156 161 clear_and_set (prelude_sev, SH_ERR_INFO); 157 else 162 else { 163 free (dup); 158 164 return -1; 165 } 159 166 p = strtok (NULL, ", \t"); 160 167 } while (p); 161 168 } 169 free(dup); 162 170 return 0; 163 171 } 164 172 165 int sh_prelude_map_info (c har * str)173 int sh_prelude_map_info (const char * str) 166 174 { 167 175 return (set_prelude_severity_int(str,(int)IDMEF_IMPACT_SEVERITY_INFO)); 168 176 } 169 int sh_prelude_map_low (c har * str)177 int sh_prelude_map_low (const char * str) 170 178 { 171 179 return (set_prelude_severity_int(str,(int)IDMEF_IMPACT_SEVERITY_LOW)); 172 180 } 173 int sh_prelude_map_medium (c har * str)181 int sh_prelude_map_medium (const char * str) 174 182 { 175 183 return (set_prelude_severity_int(str,(int)IDMEF_IMPACT_SEVERITY_MEDIUM)); 176 184 } 177 int sh_prelude_map_high (c har * str)185 int sh_prelude_map_high (const char * str) 178 186 { 179 187 return (set_prelude_severity_int(str,(int)IDMEF_IMPACT_SEVERITY_HIGH)); … … 300 308 } 301 309 310 /* flawfinder: ignore *//* is part of name, not access() */ 302 311 static void get_access_info(idmef_file_access_t *access, char * mode, int pos, int mpos) 303 312 { … … 308 317 do { 309 318 if ( mode[pos] == 'r' ) { 310 ret = idmef_file_access_new_permission(access, &str, -1); 319 /* flawfinder: ignore *//* is part of name, not access() */ 320 ret = idmef_file_access_new_permission(access, &str, IDMEF_LIST_APPEND); 311 321 if ( ret < 0 ) 312 322 return; … … 315 325 } 316 326 else if ( mode[pos] == 'w' ) { 317 ret = idmef_file_access_new_permission(access, &str, -1); 327 /* flawfinder: ignore *//* is part of name, not access() */ 328 ret = idmef_file_access_new_permission(access, &str, IDMEF_LIST_APPEND); 318 329 if ( ret < 0 ) 319 330 return; … … 322 333 } 323 334 else if ( mode[pos] == 'x' || mode[pos] == 's' || mode[pos] == 't') { 324 ret = idmef_file_access_new_permission(access, &str, -1); 335 /* flawfinder: ignore *//* is part of name, not access() */ 336 ret = idmef_file_access_new_permission(access, &str, IDMEF_LIST_APPEND); 325 337 if ( ret < 0 ) 326 338 return; … … 340 352 341 353 if ( got == 0 ) { 342 ret = idmef_file_access_new_permission(access, &str, -1); 354 /* flawfinder: ignore *//* is part of name, not access() */ 355 ret = idmef_file_access_new_permission(access, &str, IDMEF_LIST_APPEND); 343 356 if ( ret < 0 ) 344 357 return; … … 360 373 prelude_string_t *str; 361 374 idmef_checksum_t *checksum; 362 idmef_file_access_t *access; 375 idmef_file_access_t *access; /* flawfinder: ignore */ 363 376 idmef_user_id_t *userid; 364 377 const char *suffix = (category == IDMEF_FILE_CATEGORY_CURRENT) ? "_new" : "_old"; 365 378 char *mode = NULL; 366 379 367 ret = idmef_target_new_file(target, &file, -1);380 ret = idmef_target_new_file(target, &file, IDMEF_LIST_APPEND); 368 381 if ( ret < 0 ) 369 382 return; … … 429 442 ptr = get_value(msg, _("chksum"), suffix); 430 443 if ( ptr ) { 431 ret = idmef_file_new_checksum(file, &checksum, 0);444 ret = idmef_file_new_checksum(file, &checksum, IDMEF_LIST_APPEND); 432 445 if ( ret < 0 ) 433 446 return; … … 459 472 mode = get_value(msg, _("mode"), suffix); 460 473 if ( mode ) { 461 ret = idmef_file_new_file_access(file, &access, -1); 462 if ( ret < 0 ) 463 return; 464 474 /* flawfinder: ignore *//* is part of name, not access() */ 475 ret = idmef_file_new_file_access(file, &access, IDMEF_LIST_APPEND); 476 if ( ret < 0 ) 477 return; 478 479 /* flawfinder: ignore *//* is part of name, not access() */ 465 480 ret = idmef_file_access_new_user_id(access, &userid); 466 481 if ( ret < 0 ) … … 468 483 idmef_user_id_set_type(userid, IDMEF_USER_ID_TYPE_OTHER_PRIVS); 469 484 485 /* flawfinder: ignore *//* is part of name, not access() */ 470 486 get_access_info ( access, mode, 7, 9 ); 471 487 } … … 475 491 struct passwd *pw; 476 492 477 ret = idmef_file_new_file_access(file, &access, 0); 478 if ( ret < 0 ) 479 return; 480 493 /* flawfinder: ignore *//* is part of name, not access() */ 494 ret = idmef_file_new_file_access(file, &access, IDMEF_LIST_APPEND); 495 if ( ret < 0 ) 496 return; 497 498 /* flawfinder: ignore *//* is part of name, not access() */ 481 499 ret = idmef_file_access_new_user_id(access, &userid); 482 500 if ( ret < 0 ) … … 497 515 498 516 if ( mode ) { 517 /* flawfinder: ignore *//* is part of name, not access() */ 499 518 get_access_info ( access, mode, 1, 3 ); 500 519 } … … 505 524 struct group *gr; 506 525 507 ret = idmef_file_new_file_access(file, &access, -1); 508 if ( ret < 0 ) 509 return; 510 526 /* flawfinder: ignore *//* is part of name, not access() */ 527 ret = idmef_file_new_file_access(file, &access, IDMEF_LIST_APPEND); 528 if ( ret < 0 ) 529 return; 530 531 /* flawfinder: ignore *//* is part of name, not access() */ 511 532 ret = idmef_file_access_new_user_id(access, &userid); 512 533 if ( ret < 0 ) … … 527 548 528 549 if ( mode ) { 529 get_access_info ( access, mode, 4, 6 ); 550 get_access_info ( access, mode, 4, 6 ); /* flawfinder: ignore */ 530 551 } 531 552 } … … 629 650 if ( ptr ) { 630 651 if ( ! source ) { 631 ret = idmef_alert_new_source(alert, &source, -1);652 ret = idmef_alert_new_source(alert, &source, IDMEF_LIST_APPEND); 632 653 if ( ret < 0 ) { 633 654 free(ptr); … … 642 663 } 643 664 644 ret = idmef_node_new_address(node, &address, -1);665 ret = idmef_node_new_address(node, &address, IDMEF_LIST_APPEND); 645 666 if ( ret < 0 ) { 646 667 free(ptr); … … 663 684 else { 664 685 if ( ! source ) { 665 ret = idmef_alert_new_source(alert, &source, -1);686 ret = idmef_alert_new_source(alert, &source, IDMEF_LIST_APPEND); 666 687 if ( ret < 0 ) { 667 688 free(ptr); … … 696 717 idmef_user_set_category(user, IDMEF_USER_CATEGORY_OS_DEVICE); 697 718 698 ret = idmef_user_new_user_id(user, &user_id, -1);719 ret = idmef_user_new_user_id(user, &user_id, IDMEF_LIST_APPEND); 699 720 if ( ret < 0 ) { 700 721 free(ptr); … … 770 791 goto err; 771 792 772 idmef_alert_set_analyzer(alert, idmef_analyzer_ref(prelude_client_get_analyzer(client)), 0);793 idmef_alert_set_analyzer(alert, idmef_analyzer_ref(prelude_client_get_analyzer(client)), IDMEF_LIST_PREPEND); 773 794 774 795 ret = idmef_time_new_from_gettimeofday(&time); … … 786 807 goto err; 787 808 788 ret = idmef_alert_new_target(alert, &target, -1);809 ret = idmef_alert_new_target(alert, &target, IDMEF_LIST_APPEND); 789 810 if ( ret < 0 ) 790 811 goto err; … … 844 865 idmef_confidence_set_rating(confidence, IDMEF_CONFIDENCE_RATING_HIGH); 845 866 846 ret = idmef_alert_new_additional_data(alert, &data, -1);867 ret = idmef_alert_new_additional_data(alert, &data, IDMEF_LIST_APPEND); 847 868 if ( ret < 0 ) 848 869 goto err; … … 890 911 891 912 892 int sh_prelude_set_profile(c har *arg)913 int sh_prelude_set_profile(const char *arg) 893 914 { 894 915 if ( profile ) {
Note:
See TracChangeset
for help on using the changeset viewer.