Changeset e88e9e38ef3322a56040d64badb9dd6c77934d47
- Timestamp:
- 05/02/12 13:12:58
(1 year ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1335964378 -0400
- git-parent:
[d5e61dbf0c7e4b34195decd6f2b28faf0b3df9c1]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1335964378 -0400
- Message:
various memory leaks related so xmlXPathCastNodeToString and xmlGetNodePath
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rd5db0b8 |
re88e9e3 |
|
| 1790 | 1790 | noit_console_state_t *state, void *closure) { |
|---|
| 1791 | 1791 | const char *err = "internal error"; |
|---|
| 1792 | | char *path, xpath[1024]; |
|---|
| | 1792 | char *path = NULL, xpath[1024]; |
|---|
| 1793 | 1793 | noit_conf_t_userdata_t *info; |
|---|
| 1794 | 1794 | xmlXPathObjectPtr pobj = NULL; |
|---|
| … | … | |
| 1847 | 1847 | if(!strcmp(path + 1, root_node_name)) |
|---|
| 1848 | 1848 | info->path = strdup("/"); |
|---|
| 1849 | | else |
|---|
| 1850 | | info->path = strdup((char *)xmlGetNodePath(node) + 1 + |
|---|
| | 1849 | else { |
|---|
| | 1850 | char *xmlpath = (char *)xmlGetNodePath(node); |
|---|
| | 1851 | info->path = strdup(xmlpath + 1 + |
|---|
| 1851 | 1852 | strlen(root_node_name)); |
|---|
| | 1853 | free(xmlpath); |
|---|
| | 1854 | } |
|---|
| | 1855 | |
|---|
| | 1856 | if(path) free(path); |
|---|
| 1852 | 1857 | if(pobj) xmlXPathFreeObject(pobj); |
|---|
| 1853 | 1858 | if(closure) noit_console_state_pop(ncct, argc, argv, NULL, NULL); |
|---|
| 1854 | 1859 | return 0; |
|---|
| 1855 | 1860 | bad: |
|---|
| | 1861 | if(path) free(path); |
|---|
| 1856 | 1862 | if(pobj) xmlXPathFreeObject(pobj); |
|---|
| 1857 | 1863 | nc_printf(ncct, "%s [%s]\n", err, xpath); |
|---|
| r5fd1894 |
re88e9e3 |
|
| 232 | 232 | noit_conf_t_userdata_t *info; |
|---|
| 233 | 233 | char xpath[1024], newuuid_str[37]; |
|---|
| 234 | | char *uuid_conf, *wanted; |
|---|
| | 234 | char *uuid_conf = NULL, *wanted; |
|---|
| 235 | 235 | uuid_t checkid; |
|---|
| 236 | 236 | xmlXPathContextPtr xpath_ctxt = NULL; |
|---|
| … | … | |
| 303 | 303 | |
|---|
| 304 | 304 | if(info) { |
|---|
| | 305 | char *xmlpath; |
|---|
| 305 | 306 | if(info->path) free(info->path); |
|---|
| 306 | | info->path = strdup((char *)xmlGetNodePath(node) + strlen("/noit")); |
|---|
| | 307 | xmlpath = (char *)xmlGetNodePath(node); |
|---|
| | 308 | info->path = strdup(xmlpath + strlen("/noit")); |
|---|
| | 309 | free(xmlpath); |
|---|
| 307 | 310 | uuid_copy(info->current_check, checkid); |
|---|
| 308 | 311 | if(argc > 1) refresh_subchecks(ncct, info); |
|---|
| … | … | |
| 314 | 317 | } |
|---|
| 315 | 318 | out: |
|---|
| | 319 | if(uuid_conf) free(uuid_conf); |
|---|
| 316 | 320 | if(pobj) xmlXPathFreeObject(pobj); |
|---|
| 317 | 321 | return 0; |
|---|
| … | … | |
| 463 | 467 | |
|---|
| 464 | 468 | if(!INHERIT(module, mnode, module)) module = NULL; |
|---|
| 465 | | if(MYATTR(name, anode, value)) |
|---|
| | 469 | if(MYATTR(name, anode, value)) { |
|---|
| 466 | 470 | nc_printf(ncct, " name: %s\n", value); |
|---|
| | 471 | free(value); |
|---|
| | 472 | } |
|---|
| 467 | 473 | else |
|---|
| 468 | 474 | nc_printf(ncct, " name: %s [from module]\n", module ? module : "[undef]"); |
|---|
| … | … | |
| 699 | 705 | if(node->children && node->children == xmlGetLastChild(node) && |
|---|
| 700 | 706 | xmlNodeIsText(node->children)) { |
|---|
| | 707 | char *node_str, *xmlpath; |
|---|
| | 708 | node_str = (char *)xmlXPathCastNodeToString(node->children); |
|---|
| | 709 | xmlpath = (char *)xmlGetNodePath(node); |
|---|
| 701 | 710 | if(!titled++) nc_printf(ncct, "== Section Settings ==\n"); |
|---|
| 702 | | nc_printf(ncct, "%s: %s\n", xmlGetNodePath(node) + cliplen, |
|---|
| 703 | | xmlXPathCastNodeToString(node->children)); |
|---|
| | 711 | nc_printf(ncct, "%s: %s\n", xmlpath + cliplen, node_str); |
|---|
| | 712 | free(xmlpath); |
|---|
| | 713 | free(node_str); |
|---|
| 704 | 714 | } |
|---|
| 705 | 715 | } |
|---|
| … | … | |
| 743 | 753 | titled = 0; |
|---|
| 744 | 754 | for(i=0; i<cnt; i++) { |
|---|
| | 755 | char *xmlpath; |
|---|
| 745 | 756 | node = (noit_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, i); |
|---|
| 746 | 757 | if(!strcmp((char *)node->name, "check")) continue; |
|---|
| 747 | 758 | if(!strcmp((char *)node->name, "filterset")) continue; |
|---|
| 748 | | if(!strcmp((char *)xmlGetNodePath(node) + cliplen, "config")) continue; |
|---|
| 749 | | if(!(node->children && node->children == xmlGetLastChild(node) && |
|---|
| 750 | | xmlNodeIsText(node->children))) { |
|---|
| 751 | | if(!titled++) nc_printf(ncct, "== Subsections ==\n"); |
|---|
| 752 | | nc_printf(ncct, "%s\n", xmlGetNodePath(node) + cliplen); |
|---|
| 753 | | } |
|---|
| | 759 | xmlpath = (char *)xmlGetNodePath(node); |
|---|
| | 760 | if(strcmp(xmlpath + cliplen, "config")) { |
|---|
| | 761 | if(!(node->children && node->children == xmlGetLastChild(node) && |
|---|
| | 762 | xmlNodeIsText(node->children))) { |
|---|
| | 763 | if(!titled++) nc_printf(ncct, "== Subsections ==\n"); |
|---|
| | 764 | nc_printf(ncct, "%s\n", xmlpath + cliplen); |
|---|
| | 765 | } |
|---|
| | 766 | } |
|---|
| | 767 | free(xmlpath); |
|---|
| 754 | 768 | } |
|---|
| 755 | 769 | |
|---|
| … | … | |
| 773 | 787 | int busted = 1; |
|---|
| 774 | 788 | xmlAttr *attr; |
|---|
| 775 | | char *uuid_str = "undefined"; |
|---|
| | 789 | char *uuid_str = NULL; |
|---|
| | 790 | uuid_t checkid; |
|---|
| 776 | 791 | |
|---|
| 777 | 792 | if(!titled++) nc_printf(ncct, "== Checks ==\n"); |
|---|
| 778 | 793 | |
|---|
| 779 | 794 | for(attr=node->properties; attr; attr = attr->next) { |
|---|
| 780 | | if(!strcmp((char *)attr->name, "uuid")) |
|---|
| | 795 | if(!strcmp((char *)attr->name, "uuid")) { |
|---|
| 781 | 796 | uuid_str = (char *)xmlXPathCastNodeToString(attr->children); |
|---|
| 782 | | } |
|---|
| 783 | | if(uuid_str) { |
|---|
| 784 | | uuid_t checkid; |
|---|
| 785 | | nc_printf(ncct, "check[@uuid=\"%s\"] ", uuid_str); |
|---|
| 786 | | if(uuid_parse(uuid_str, checkid) == 0) { |
|---|
| 787 | | noit_check_t *check; |
|---|
| 788 | | check = noit_poller_lookup(checkid); |
|---|
| 789 | | if(check) { |
|---|
| 790 | | busted = 0; |
|---|
| 791 | | nc_printf(ncct, "%s`%s`%s", check->target, check->module, check->name); |
|---|
| 792 | | } |
|---|
| | 797 | break; |
|---|
| 793 | 798 | } |
|---|
| 794 | 799 | } |
|---|
| 795 | | else |
|---|
| 796 | | nc_printf(ncct, "%s ", xmlGetNodePath(node) + cliplen); |
|---|
| | 800 | nc_printf(ncct, "check[@uuid=\"%s\"] ", uuid_str ? uuid_str : "undefined"); |
|---|
| | 801 | if(uuid_str && uuid_parse(uuid_str, checkid) == 0) { |
|---|
| | 802 | noit_check_t *check; |
|---|
| | 803 | check = noit_poller_lookup(checkid); |
|---|
| | 804 | if(check) { |
|---|
| | 805 | busted = 0; |
|---|
| | 806 | nc_printf(ncct, "%s`%s`%s", check->target, check->module, check->name); |
|---|
| | 807 | } |
|---|
| | 808 | } |
|---|
| | 809 | if(uuid_str) free(uuid_str); |
|---|
| 797 | 810 | if(busted) nc_printf(ncct, "[check not in running system]"); |
|---|
| 798 | 811 | nc_write(ncct, "\n", 1); |
|---|
| r66dbd3e |
re88e9e3 |
|
| 449 | 449 | |
|---|
| 450 | 450 | if(info) { |
|---|
| | 451 | char *xmlpath = NULL; |
|---|
| 451 | 452 | if(info->path) free(info->path); |
|---|
| 452 | | info->path = strdup((char *)xmlGetNodePath(fsnode) + strlen("/noit")); |
|---|
| | 453 | xmlpath = (char *)xmlGetNodePath(fsnode); |
|---|
| | 454 | info->path = strdup(xmlpath + strlen("/noit")); |
|---|
| | 455 | free(xmlpath); |
|---|
| 453 | 456 | strlcpy(info->filter_name, argv[0], sizeof(info->filter_name)); |
|---|
| 454 | 457 | if(state) { |
|---|