ossec / ossec-hids

OSSEC is an Open Source Host-based Intrusion Detection System that performs log analysis, file integrity checking, policy monitoring, rootkit detection, real-time alerting and active response.
http://www.ossec.net
Other
4.34k stars 1.02k forks source link

Bug: In the func save_agentless_entry, file-ptr opened but not close #2027

Open coolc4 opened 2 years ago

coolc4 commented 2 years ago

/ Save agentless entry for the control tools to gather / static int save_agentless_entry(const char host, const char script, const char agttype) { FILE fp; char sys_location[1024 + 1];

sys_location[1024] = '\0';
snprintf(sys_location, 1024, "%s/(%s) %s",
         AGENTLESS_ENTRYDIRPATH, script, host);

fp = fopen(sys_location, "w");
if (fp) {
    fprintf(fp, "type: %s\n", agttype);
    fclose(fp);
} else {
    merror(FOPEN_ERROR, ARGV0, sys_location, errno, strerror(errno));
}

**//lost fclose(fp)**
return (0);

}

coolc4 commented 2 years ago

And I fixed the bug by th patch: ossec_agentlessd_fdnotclose.txt