Skip to content
4 changes: 3 additions & 1 deletion src/addagent/validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ int OS_RemoveAgent(const char *u_id) {
return 0;

#ifndef WIN32
chmod(AUTH_FILE, 0440);
if((chmod(AUTH_FILE, 0440)) < 0) {
merror("addagent: ERROR: Cannot chmod %s: %s", AUTH_FILE, strerror(errno));
}
#endif

#ifdef REUSE_ID
Expand Down
13 changes: 12 additions & 1 deletion src/monitord/sendcustomemail.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,12 @@ int OS_SendCustomEmail2(char **to, char *subject, char *smtpserver, char *from,
if (replyto) {
memset(snd_msg, '\0', 128);
snprintf(snd_msg, 127, REPLYTO, replyto);
OS_SendTCP(socket, snd_msg);
if(sendmail) {
fprintf(sendmail, "%s", snd_msg);
} else {
OS_SendTCP(socket, snd_msg);
}

}

/* Add CCs */
Expand Down Expand Up @@ -269,6 +274,12 @@ int OS_SendCustomEmail2(char **to, char *subject, char *smtpserver, char *from,
fp = fopen(fname2, "r");
if(!fp) {
merror("%s: ERROR: Cannot open %s: %s", __local_name, fname2, strerror(errno));
if(socket) {
close(socket);
}
if(sendmail) {
pclose(sendmail);
}
return(1);
}

Expand Down
5 changes: 5 additions & 0 deletions src/os_auth/main-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ char *__generatetmppass()
snprintf(str1, STR_SIZE, "%d%d%s%d%s%s",(int)time(0), rand1, muname, rand2, md3, md4);
OS_MD5_Str(str1, md1);
fstring = strdup(md1);
free(rand3);
free(rand4);
if(muname) {
free(muname);
}
return(fstring);
}

Expand Down
12 changes: 11 additions & 1 deletion src/os_maild/sendcustomemail.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ int OS_SendCustomEmail(char **to, char *subject, char *smtpserver, char *from, c
if (replyto) {
memset(snd_msg, '\0', 128);
snprintf(snd_msg, 127, REPLYTO, replyto);
OS_SendTCP(socket, snd_msg);
if(sendmail) {
fprintf(sendmail, "%s", snd_msg);
} else {
OS_SendTCP(socket, snd_msg);
}
}

/* Add CCs */
Expand Down Expand Up @@ -260,6 +264,12 @@ int OS_SendCustomEmail(char **to, char *subject, char *smtpserver, char *from, c
fp = fopen(fname, "r");
if(!fp) {
merror("%s: ERROR: Cannot open %s: %s", __local_name, fname, strerror(errno));
if(socket) {
close(socket);
}
if(sendmail) {
pclose(sendmail);
}
return(1);
}

Expand Down
6 changes: 6 additions & 0 deletions src/os_net/os_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ int OS_Connect(char *_port, unsigned int protocol, const char *_ip)
s = getaddrinfo(_ip, _port, &hints, &result);
if (s != 0) {
verbose("getaddrinfo: %s", gai_strerror(s));
if(result) {
freeaddrinfo(result);
}
return(OS_INVALID);
}

Expand Down Expand Up @@ -401,6 +404,9 @@ int OS_Connect(char *_port, unsigned int protocol, const char *_ip)
}
if (rp == NULL) { /* No address succeeded */
OS_CloseSocket(ossock);
if(result) {
freeaddrinfo(result);
}
return(OS_SOCKTERR);
}
satop(rp->ai_addr, tempaddr, sizeof tempaddr);
Expand Down
8 changes: 7 additions & 1 deletion src/shared/file_op.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ char *GetRandomNoise()
{
FILE *fp;
char buf[2048 + 1];
size_t frr = 0;

/* Reading urandom */
fp = fopen("/dev/urandom", "r");
Expand All @@ -375,7 +376,12 @@ char *GetRandomNoise()
}

buf[2048] = '\0';
fread(buf, 1, 2048, fp);
frr = fread(buf, 1, 2048, fp);
if(frr == 0) {
merror("ERROR: GetRandomNoise() fread() returned 0.");
fclose(fp);
return(NULL);
}
return(strdup(buf));
}

Expand Down
2 changes: 1 addition & 1 deletion src/shared/rules_op.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ int OS_ReadXMLRules(const char *rulefile,
config_ruleinfo->ckignore |= FTS_LOCATION;
}
if (strstr(rule_opt[k]->content, "data") != NULL) {
config_ruleinfo->ignore |= FTS_DATA;
config_ruleinfo->ckignore |= FTS_DATA;
}
if (strstr(rule_opt[k]->content, "name") != NULL) {
config_ruleinfo->ckignore |= FTS_NAME;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/validate_op.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ int sacmp(struct sockaddr *sa1, struct sockaddr *sa2, int prefixlength)
realaf2 = AF_INET6;
if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *) addr2)) {
/* shift the pointer for a mapped address */
addr1 += (sizeof (struct in6_addr)) - (sizeof (struct in_addr));
addr2 += (sizeof (struct in6_addr)) - (sizeof (struct in_addr));
realaf2 = AF_INET;
}
break;
Expand Down
1 change: 1 addition & 0 deletions src/syscheckd/run_realtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ int realtime_process()
if (len < 0) {
merror("%s: ERROR: Unable to read from real time buffer.", ARGV0);
} else if (len > 0) {
buf[len] = '\0';
while (i < (size_t) len) {
event = (struct inotify_event *) (void *) &buf[i];

Expand Down
4 changes: 3 additions & 1 deletion src/syscheckd/seechanges.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ char *seechanges_addfile(const char *filename)
);


rename(old_location, tmp_location);
if((rename(old_location, tmp_location)) < 0) {
merror("%s: ERROR rename of %s failed: %s", ARGV0, old_location, strerror(errno));
}
if(seechanges_dupfile(filename, old_location) != 1)
{
merror("%s: ERROR: Unable to create snapshot for %s",ARGV0, filename);
Expand Down