Skip to content

Commit

Permalink
netout: add minimal sanity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
f00b4r0 committed Jul 30, 2024
1 parent 5131a27 commit 4ce37bd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion netout.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ void Netoutpp(acarsmsg_t *msg)
char *pstr;
int res;

if (!msg)
return;

char *txt = strdup(msg->txt);
for (pstr = txt; *pstr != 0; pstr++)
if (*pstr == '\n' || *pstr == '\r')
Expand All @@ -112,6 +115,9 @@ void Netoutsv(acarsmsg_t *msg, char *idstation, int chn, struct timeval tv)
struct tm tmp;
int res;

if (!msg)
return;

gmtime_r(&(tv.tv_sec), &tmp);

res = snprintf(pkt, sizeof(pkt),
Expand All @@ -126,5 +132,6 @@ void Netoutsv(acarsmsg_t *msg, char *idstation, int chn, struct timeval tv)

void Netoutjson(char *jsonbuf)
{
Netwrite(jsonbuf, strlen(jsonbuf));
if (jsonbuf)
Netwrite(jsonbuf, strlen(jsonbuf));
}

0 comments on commit 4ce37bd

Please sign in to comment.