-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Server: Check for invalid floats in all packets
This adds checks for nan/inf in all instances where a float is read from a packet, and drops it if an invalid value is found. The vector3f_t check is located in a new file, VectorChecks.c. Credits to burner (DavidCo113 <davidco7777@protonmail.com>) for telling me about this.
- Loading branch information
Showing
6 changed files
with
67 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <Util/Checks/VectorChecks.h> | ||
#include <Util/Types.h> | ||
#include <math.h> | ||
|
||
inline uint8_t valid_vec3f(vector3f_t vec) | ||
{ | ||
return !(isnan(vec.x) || isnan(vec.y) || isnan(vec.z) || | ||
isinf(vec.x) || isinf(vec.y) || isinf(vec.z)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef VECTOR_CHECKS_H | ||
#define VECTOR_CHECKS_H | ||
|
||
#include <Util/Types.h> | ||
|
||
uint8_t valid_vec3f(vector3f_t vec); | ||
|
||
#endif |