Merge pull request #40 from wiedehopf/overflow_fix

Overflow fix
This commit is contained in:
Eric Tran 2019-04-09 08:52:11 -05:00 committed by GitHub
commit d54c452683
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;
@ -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)
@ -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));
@ -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));
@ -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));