Skip to content
Browse files

changed bzero() to memset()

changed bzero() to memset() as bzero is deprecated.

replaced bzero() with memset()

replaced calls to bzero() with memset() as bzero is deprecated.

replaced bcopy() with memmove()

Replaced deprecated bcopy() with memmove(), memmove is guaranteed to
work even if memory areas overlap, where as memcpy is designed so that
the memory areas MUST not overlap.

replaced bzero() with memset()

Replaced bzero() with memset() as bzero is deprecated.

replaced bzero() with memset()

changed bzero() which is deprecated to memset().

replaced deprecated function calls

replaced bzero() with memset() and
bcopy() with memmove().

changed bzero to memset

changed bzero() to memset in #define, bzero deprecated.

replaced bzero() with memset()

replaced bzero() with memset() as bzero is deprecated.

changed function prototype

corrected function prototype for PlatypusAgentReceive to match actual
function later in file.

corrected function prototype and deprecated calls

changed function prototype for SguilRecvAgentMsg() and changed bzero()
to memset() as bzero() is deprecated

replaced bzero() with memset()

replaced bzero() with memset() since bzero() is deprecated.
  • Loading branch information...
1 parent 166539c commit 4ec8a92374aa5e3dd1c23d9def871114b9947abb @dogbert2 dogbert2 committed with binf
View
2 src/barnyard2.c
@@ -1083,7 +1083,7 @@ static void Barnyard2Cleanup(int exit_val)
struct timeval difftime;
struct timezone tz;
- bzero((char *) &tz, sizeof(tz));
+ memset((char *) &tz, 0, sizeof(tz)); /* bzero() deprecated, replaced by memset() */
gettimeofday(&endtime, &tz);
TIMERSUB(&endtime, &starttime, &difftime);
View
32 src/log.c
@@ -362,7 +362,7 @@ void PrintIPPkt(FILE * fp, int type, Packet * p)
DEBUG_WRAP(DebugMessage(DEBUG_LOG, "PrintIPPkt type = %d\n", type););
- bzero((char *) timestamp, TIMEBUF_SIZE);
+ memset((char *) timestamp, 0, TIMEBUF_SIZE); /* bzero() deprecated, replaced with memset */
ts_print((struct timeval *) & p->pkth->ts, timestamp);
/* dump the timestamp */
@@ -864,8 +864,8 @@ void PrintArpHeader(FILE * fp, Packet * p)
const uint8_t *mac_src = NULL;
const uint8_t *mac_dst = NULL;
- bzero((struct in_addr *) &ip_addr, sizeof(struct in_addr));
- bzero((char *) timestamp, TIMEBUF_SIZE);
+ memset((struct in_addr *) &ip_addr, 0, sizeof(struct in_addr)); /* bzero() deprecated, replaced with memset() */
+ memset((char *) timestamp, 0, TIMEBUF_SIZE); /* bzero() deprecated, replaced with memset() */
ts_print((struct timeval *) & p->pkth->ts, timestamp);
/* determine what to use as MAC src and dst */
@@ -1468,7 +1468,7 @@ void PrintICMPEmbeddedIP(FILE *fp, Packet *p)
if (fp == NULL || p == NULL)
return;
- bzero((char *) &op, sizeof(Packet));
+ memset((char *) &op, 0, sizeof(Packet)); /* bzero() deprecated, replaced with memset() */
orig_p = &op;
orig_p->iph = p->orig_iph;
@@ -1718,7 +1718,7 @@ void PrintTcpOptions(FILE * fp, Packet * p)
switch(p->tcp_options[i].code)
{
case TCPOPT_MAXSEG:
- bzero((char *) tmp, 5);
+ memset((char *) tmp, 0, 5); /* bzero() deprecated, replaced with memset() */
fwrite("MSS: ", 5, 1, fp);
if (p->tcp_options[i].data)
memcpy(tmp, p->tcp_options[i].data, 2);
@@ -1741,11 +1741,11 @@ void PrintTcpOptions(FILE * fp, Packet * p)
break;
case TCPOPT_SACK:
- bzero((char *) tmp, 5);
+ memset((char *) tmp, 0, 5); /* bzero() deprecated, replaced by memset() */
if (p->tcp_options[i].data && (p->tcp_options[i].len >= 2))
memcpy(tmp, p->tcp_options[i].data, 2);
fprintf(fp, "Sack: %u@", EXTRACT_16BITS(tmp));
- bzero((char *) tmp, 5);
+ memset((char *) tmp, 0, 5); /* bzero() deprecated, replaced by memset() */
if (p->tcp_options[i].data && (p->tcp_options[i].len >= 4))
memcpy(tmp, (p->tcp_options[i].data) + 2, 2);
fprintf(fp, "%u ", EXTRACT_16BITS(tmp));
@@ -1756,46 +1756,46 @@ void PrintTcpOptions(FILE * fp, Packet * p)
break;
case TCPOPT_ECHO:
- bzero((char *) tmp, 5);
+ memset((char *) tmp, 0, 5); /* bzero() deprecated, replaced by memset() */
if (p->tcp_options[i].data)
memcpy(tmp, p->tcp_options[i].data, 4);
fprintf(fp, "Echo: %u ", EXTRACT_32BITS(tmp));
break;
case TCPOPT_ECHOREPLY:
- bzero((char *) tmp, 5);
+ memset((char *) tmp, 0, 5); /* bzero() deprecated, replaced by memset() */
if (p->tcp_options[i].data)
memcpy(tmp, p->tcp_options[i].data, 4);
fprintf(fp, "Echo Rep: %u ", EXTRACT_32BITS(tmp));
break;
case TCPOPT_TIMESTAMP:
- bzero((char *) tmp, 5);
+ memset((char *) tmp, 0, 5); /* bzero() deprecated, replaced by memset() */
if (p->tcp_options[i].data)
memcpy(tmp, p->tcp_options[i].data, 4);
fprintf(fp, "TS: %u ", EXTRACT_32BITS(tmp));
- bzero((char *) tmp, 5);
+ memset((char *) tmp, 0, 5); /* bzero() deprecated, replaced by memset() */
if (p->tcp_options[i].data)
memcpy(tmp, (p->tcp_options[i].data) + 4, 4);
fprintf(fp, "%u ", EXTRACT_32BITS(tmp));
break;
case TCPOPT_CC:
- bzero((char *) tmp, 5);
+ memset((char *) tmp, 0, 5); /* bzero() deprecated, replaced by memset() */
if (p->tcp_options[i].data)
memcpy(tmp, p->tcp_options[i].data, 4);
fprintf(fp, "CC %u ", EXTRACT_32BITS(tmp));
break;
case TCPOPT_CCNEW:
- bzero((char *) tmp, 5);
+ memset((char *) tmp, 0, 5); /* bzero() deprecated, replaced by memset() */
if (p->tcp_options[i].data)
memcpy(tmp, p->tcp_options[i].data, 4);
fprintf(fp, "CCNEW: %u ", EXTRACT_32BITS(tmp));
break;
case TCPOPT_CCECHO:
- bzero((char *) tmp, 5);
+ memset((char *) tmp, 0, 5); /* bzero() deprecated, replaced by memset() */
if (p->tcp_options[i].data)
memcpy(tmp, p->tcp_options[i].data, 4);
fprintf(fp, "CCECHO: %u ", EXTRACT_32BITS(tmp));
@@ -1848,7 +1848,7 @@ void PrintEapolPkt(FILE * fp, Packet * p)
char timestamp[TIMEBUF_SIZE];
- bzero((char *) timestamp, TIMEBUF_SIZE);
+ memset((char *) timestamp, 0, TIMEBUF_SIZE); /* bzero() deprecated, replaced by memset() */
ts_print((struct timeval *) & p->pkth->ts, timestamp);
/* dump the timestamp */
@@ -2022,7 +2022,7 @@ void PrintWifiPkt(FILE * fp, Packet * p)
char timestamp[TIMEBUF_SIZE];
- bzero((char *) timestamp, TIMEBUF_SIZE);
+ memset((char *) timestamp, 0, TIMEBUF_SIZE); /* bzero() deprecated, replaced by memset() */
ts_print((struct timeval *) & p->pkth->ts, timestamp);
/* dump the timestamp */
View
13 src/log_text.c
@@ -1603,7 +1603,8 @@ void LogArpHeader(TextLog* log, Packet * p)
switch(ntohs(p->ah->ea_hdr.ar_op))
{
case ARPOP_REQUEST:
- bcopy((void *)p->ah->arp_tpa, (void *) &ip_addr, sizeof(ip_addr));
+ /* bcopy() deprecated, replaced with memmove() */
+ memmove((void *) &ip_addr, (void *)p->ah->arp_tpa, sizeof(ip_addr));
TextLog_Print(log, "ARP who-has %s", inet_ntoa(ip_addr));
if(memcmp((char *) ezero, (char *) p->ah->arp_tha, 6) != 0)
@@ -1612,8 +1613,8 @@ void LogArpHeader(TextLog* log, Packet * p)
p->ah->arp_tha[1], p->ah->arp_tha[2], p->ah->arp_tha[3],
p->ah->arp_tha[4], p->ah->arp_tha[5]);
}
- bcopy((void *)p->ah->arp_spa, (void *) &ip_addr, sizeof(ip_addr));
-
+ /* bcopy() deprecated, replaced with memmove() */
+ memmove((void *) &ip_addr, (void *)p->ah->arp_spa, sizeof(ip_addr));
TextLog_Print(log, " tell %s", inet_ntoa(ip_addr));
if(memcmp((char *) mac_src, (char *) p->ah->arp_sha, 6) != 0)
@@ -1625,7 +1626,8 @@ void LogArpHeader(TextLog* log, Packet * p)
break;
case ARPOP_REPLY:
- bcopy((void *)p->ah->arp_spa, (void *) &ip_addr, sizeof(ip_addr));
+ /* bcopy() deprecated, replaced with memmove() */
+ memmove((void *) &ip_addr, (void *)p->ah->arp_spa, sizeof(ip_addr));
TextLog_Print(log, "ARP reply %s", inet_ntoa(ip_addr));
/* print out the originating request if we're on a weirder
@@ -1658,7 +1660,8 @@ void LogArpHeader(TextLog* log, Packet * p)
break;
case ARPOP_RREPLY:
- bcopy((void *)p->ah->arp_tpa, (void *) &ip_addr, sizeof(ip_addr));
+ /* bcopy() deprecated, replaced with memmove() */
+ memmove((void *) &ip_addr, (void *)p->ah->arp_tpa, sizeof(ip_addr));
TextLog_Print(log, "RARP reply %X:%X:%X:%X:%X:%X at %s",
p->ah->arp_tha[0], p->ah->arp_tha[1], p->ah->arp_tha[2],
p->ah->arp_tha[3], p->ah->arp_tha[4], p->ah->arp_tha[5],
View
8 src/map.c
@@ -258,7 +258,7 @@ int ReadReferenceFile(Barnyard2Config *bc, const char *file)
return -1;
}
- bzero(buf, BUFFER_SIZE);
+ memset(buf, 0, BUFFER_SIZE); /* bzero() deprecated, replaced with memset() */
while ( fgets(buf, BUFFER_SIZE, fd) != NULL )
{
@@ -459,7 +459,7 @@ int ReadClassificationFile(Barnyard2Config *bc, const char *file)
return -1;
}
- bzero(buf, BUFFER_SIZE);
+ memset(buf, 0, BUFFER_SIZE); /* bzero() deprecated, replaced with memset() */
while ( fgets(buf, BUFFER_SIZE, fd) != NULL )
{
@@ -513,7 +513,7 @@ int ReadSidFile(Barnyard2Config *bc, const char *file)
return -1;
}
- bzero(buf, BUFFER_SIZE);
+ memset(buf, 0, BUFFER_SIZE); /* bzero() deprecated, replaced by memset() */
while(fgets(buf, BUFFER_SIZE, fd) != NULL)
{
@@ -705,7 +705,7 @@ int ReadGenFile(Barnyard2Config *bc, const char *file)
return -1;
}
- bzero(buf, BUFFER_SIZE);
+ memset(buf, 0, BUFFER_SIZE); /* bzero() deprecated, replaced by memset() */
while( fgets(buf, BUFFER_SIZE, fd) != NULL )
{
View
18 src/output-plugins/spo_alert_unixsock.c
@@ -176,17 +176,18 @@ void AlertUnixSock(Packet *p, void *event, uint32_t event_type, void *arg)
DEBUG_WRAP(DebugMessage(DEBUG_LOG, "Logging Alert data!\n"););
- bzero((char *)&alertpkt,sizeof(alertpkt));
+ memset((char *)&alertpkt, 0, sizeof(alertpkt)); /* bzero() deprecated, replaced with memset() */
if (event)
{
- bcopy((const void *)event,(void *)&alertpkt.event,sizeof(Unified2EventCommon));
+ memmove((void *) &alertpkt.event, (const void *)event, sizeof(Unified2EventCommon)); /* bcopy() deprecated, replaced by memmove() */
}
if(p && p->pkt)
{
- bcopy((const void *)p->pkth,(void *)&alertpkt.pkth,sizeof(struct pcap_pkthdr));
- bcopy((const void *)p->pkt,alertpkt.pkt,
- alertpkt.pkth.caplen > SNAPLEN? SNAPLEN : alertpkt.pkth.caplen);
+ /* bcopy() deprecated, replaced by memmove() */
+ memmove((void *) &alertpkt.pkth, (const void *)p->pkth, sizeof(struct pcap_pkthdr));
+ memmmove(alertpkt.pkt, (const void *)p->pkt,
+ alertpkt.pkth.caplen > SNAPLEN ? SNAPLEN : alertpkt.pkth.caplen);
}
else
alertpkt.val|=NOPACKET_STRUCT;
@@ -196,8 +197,9 @@ void AlertUnixSock(Packet *p, void *event, uint32_t event_type, void *arg)
if (sn != NULL)
{
- bcopy((const void *)sn->msg,(void *)alertpkt.alertmsg,
- strlen(sn->msg)>ALERTMSG_LENGTH-1 ? ALERTMSG_LENGTH - 1 : strlen(sn->msg));
+ /* bcopy() deprecated, replaced by memmove() */
+ memmove((void *) alertpkt.alertmsg, (const void *) sn->msg,
+ strlen(sn->msg) > ALERTMSG_LENGTH-1 ? ALERTMSG_LENGTH - 1 : strlen(sn->msg));
}
/* some data which will help monitoring utility to dissect packet */
@@ -285,7 +287,7 @@ void OpenAlertSock(void)
srv);
}
- bzero((char *) &alertaddr, sizeof(alertaddr));
+ memset((char *) &alertaddr, 0, sizeof(alertaddr)); /* bzero() deprecated, replaced with memset() */
/* 108 is the size of sun_path */
strncpy(alertaddr.sun_path, srv, 108);
View
2 src/output-plugins/spo_database.h
@@ -539,7 +539,7 @@ void DatabaseSetup(void);
/* this is for debugging purposes only */
static char g_CurrentStatement[2048];
#define SAVESTATEMENT(str) strncpy(g_CurrentStatement, str, sizeof(g_CurrentStatement) - 1);
- #define CLEARSTATEMENT() bzero((char *) g_CurrentStatement, sizeof(g_CurrentStatement));
+ #define CLEARSTATEMENT() memset((char *) g_CurrentStatement, 0, sizeof(g_CurrentStatement));
#else
#define SAVESTATEMENT(str) NULL;
#define CLEARSTATEMENT() NULL;
View
6 src/output-plugins/spo_log_ascii.c
@@ -205,9 +205,9 @@ FILE *OpenLogFile(int mode, Packet * p)
#endif
/* zero out our buffers */
- bzero((char *) log_path, STD_BUF);
- bzero((char *) log_file, STD_BUF);
- bzero((char *) proto, 5);
+ memset((char *) log_path, 0, STD_BUF); /* bzero() deprecated, replaced by memset() */
+ memset((char *) log_file, 0, STD_BUF); /* bzero() deprecated, replaced by memset() */
+ memset((char *) proto, 0, 5); /* bzero() deprecated, replaced by memset() */
if (mode == GENERIC_LOG || mode == DUMP || mode == BOGUS ||
mode == NON_IP || mode == ARP)
View
2 src/output-plugins/spo_platypus.c
@@ -90,7 +90,7 @@ int PlatypusAgentConnect(SpoPlatypusData *);
int PlatypusAgentInit(SpoPlatypusData *);
int PlatypusAgentEventSend(SpoPlatypusData *, char *);
int PlatypusAgentSend(SpoPlatypusData *, char *);
-int PlatypusAgentReceive();
+int PlatypusAgentReceive(SpoPlatypusData *, char *);
char *PlatypusTimestamp(u_int32_t, u_int32_t);
View
12 src/output-plugins/spo_sguil.c
@@ -112,7 +112,7 @@ int SguilSensorAgentConnect(SpoSguilData *);
int SguilSensorAgentInit(SpoSguilData *);
int SguilRTEventMsg(SpoSguilData *, char *);
int SguilSendAgentMsg(SpoSguilData *, char *);
-int SguilRecvAgentMsg();
+int SguilRecvAgentMsg(SpoSguilData *, char *);
char *SguilTimestamp(u_int32_t);
@@ -230,7 +230,7 @@ void Sguil(Packet *p, void *event, uint32_t event_type, void *arg)
ClassType *cn = NULL;
Tcl_DString list;
- bzero(buffer, TMP_BUFFER);
+ memset(buffer, 0, TMP_BUFFER); /* bzero() deprecated, replaced by memset() */
if ( event == NULL || arg == NULL )
{
@@ -592,7 +592,7 @@ int SguilAppendIPHdrData(Tcl_DString *list, Packet *p)
{
char buffer[TMP_BUFFER];
- bzero(buffer, TMP_BUFFER);
+ memset(buffer, 0, TMP_BUFFER); /* bzero() deprecated, replaced by memset() */
SnortSnprintf(buffer, TMP_BUFFER, "%u", ntohl(p->iph->ip_src.s_addr));
Tcl_DStringAppendElement(list, buffer);
@@ -667,7 +667,7 @@ int SguilAppendICMPData(Tcl_DString *list, Packet *p)
int i;
char buffer[TMP_BUFFER];
- bzero(buffer, TMP_BUFFER);
+ memset(buffer, 0, TMP_BUFFER); /* bzero() deprecated, replaced by memset() */
if (!p->icmph)
{
@@ -742,7 +742,7 @@ int SguilAppendTCPData(Tcl_DString *list, Packet *p)
int i;
char buffer[TMP_BUFFER];
- bzero(buffer, TMP_BUFFER);
+ memset(buffer, 0, TMP_BUFFER); /* bzero() deprecated, replaced by memset() */
/* empty elements for icmp data */
for(i=0; i < 5; i++)
@@ -804,7 +804,7 @@ int SguilAppendUDPData(Tcl_DString *list, Packet *p)
int i;
char buffer[TMP_BUFFER];
- bzero(buffer, TMP_BUFFER);
+ memset(buffer, 0, TMP_BUFFER); /* bzero() deprecated, replaced by memset() */
/* empty elements for ICMP data */
for(i=0; i < 5; i++)
View
10 src/parser.c
@@ -1100,7 +1100,7 @@ static char * ExpandVars(Barnyard2Config *bc, char *string)
if(!string || !*string || !strchr(string, '$'))
return(string);
- bzero((char *) estring, PARSERULE_SIZE);
+ memset((char *) estring, 0, PARSERULE_SIZE); /* bzero() deprecated, replaced by memset() */
i = j = 0;
l_string = strlen(string);
@@ -1119,7 +1119,7 @@ static char * ExpandVars(Barnyard2Config *bc, char *string)
if(c == '$' && !quote_toggle)
{
- bzero((char *) rawvarname, sizeof(rawvarname));
+ memset((char *) rawvarname, 0, sizeof(rawvarname)); /* bzero() deprecated, replaced by memset() */
varname_completed = 0;
name_only = 1;
iv = i;
@@ -1159,8 +1159,8 @@ static char * ExpandVars(Barnyard2Config *bc, char *string)
varcontents = NULL;
- bzero((char *) varname, sizeof(varname));
- bzero((char *) varaux, sizeof(varaux));
+ memset((char *) varname, 0, sizeof(varname)); /* bzero() deprecated, replaced by memset() */
+ memset((char *) varaux, 0, sizeof(varaux)); /* bzero() deprecated, replaced by memset() */
varmodifier = ' ';
p = strchr(rawvarname, ':');
@@ -1177,7 +1177,7 @@ static char * ExpandVars(Barnyard2Config *bc, char *string)
else
SnortStrncpy(varname, rawvarname, sizeof(varname));
- bzero((char *) varbuffer, sizeof(varbuffer));
+ memset((char *) varbuffer, 0, sizeof(varbuffer)); /* bzero() deprecated, replaced by memset() */
varcontents = VarSearch(bc, varname);
View
4 src/util.c
@@ -201,7 +201,7 @@ void ts_print(register const struct timeval *tvp, char *timebuf)
if(!tvp)
{
/* manual page (for linux) says tz is never used, so.. */
- bzero((char *) &tz, sizeof(tz));
+ memset((char *) &tz, 0, sizeof(tz)); /* bzero() deprecated, replaced by memset() */
gettimeofday(&tv, &tz);
tvp = &tv;
}
@@ -2100,7 +2100,7 @@ char *GetCurrentTimestamp(void)
buf = (char *)SnortAlloc(SMALLBUFFER * sizeof(char));
- bzero((char *)&tz,sizeof(tz));
+ memset((char *)&tz, 0, sizeof(tz)); /* bzero() deprecated, replaced by memset() */
gettimeofday(&tv,&tz);
tvp = &tv;

0 comments on commit 4ec8a92

Please sign in to comment.
Something went wrong with that request. Please try again.