Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overflow fix #40

Merged
merged 2 commits into from
Apr 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions net_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ char *generateStatsJson(const char *url_path, int *len) {
p = appendStatsJson(p, end, &add, "total");
p = safe_snprintf(p, end, "\n}\n");

assert(p <= end);
assert(p < end);

*len = p-buf;
return buf;
Expand Down Expand Up @@ -1878,7 +1878,7 @@ __attribute__ ((format (printf,4,5))) static char *appendFATSV(char *p, char *en
return p;
}

#define TSV_MAX_PACKET_SIZE 600
#define TSV_MAX_PACKET_SIZE 800
#define TSV_VERSION "4E"

static void writeFATSVPositionUpdate(float lat, float lon, float alt)
Expand Down Expand Up @@ -1908,7 +1908,7 @@ static void writeFATSVPositionUpdate(float lat, float lon, float alt)
--p; // remove last tab
p = safe_snprintf(p, end, "\n");

if (p <= end)
if (p < end)
completeWrite(&Modes.fatsv_out, p);
else
fprintf(stderr, "fatsv: output too large (max %d, overran by %d)\n", TSV_MAX_PACKET_SIZE, (int) (p - end));
Expand All @@ -1935,7 +1935,7 @@ static void writeFATSVEventMessage(struct modesMessage *mm, const char *datafiel
}
p = safe_snprintf(p, end, "\n");

if (p <= end)
if (p < end)
completeWrite(&Modes.fatsv_out, p);
else
fprintf(stderr, "fatsv: output too large (max %d, overran by %d)\n", TSV_MAX_PACKET_SIZE, (int) (p - end));
Expand Down Expand Up @@ -2256,7 +2256,7 @@ static void writeFATSV()
--p; // remove last tab
p = safe_snprintf(p, end, "\n");

if (p <= end)
if (p < end)
completeWrite(&Modes.fatsv_out, p);
else
fprintf(stderr, "fatsv: output too large (max %d, overran by %d)\n", TSV_MAX_PACKET_SIZE, (int) (p - end));
Expand Down