summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-07-09 21:15:35 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2019-07-10 05:11:47 +0300
commit9eb860d45d65a822e7336afce59bb06d68a90c72 (patch)
treeb48fa40130f0290d8e2871ac2145d973687d4cd4 /core
parent25bee36fcc06f52761f07ec3957c9a8663c6b39e (diff)
downloadsubsurface-9eb860d45d65a822e7336afce59bb06d68a90c72.tar.gz
Git: handle excess of cylinders or weightsystems gracefully
Currently, the git parser happily trashes memory if a git repository contains too many weightsystems or cylinders. This should only happen in testing, but nevertheless try to handle it gracefully and ignore excess cylinders / weightsystems. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r--core/load-git.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/load-git.c b/core/load-git.c
index 51849501a..ee31e99ac 100644
--- a/core/load-git.c
+++ b/core/load-git.c
@@ -391,6 +391,9 @@ static void parse_dive_cylinder(char *line, struct membuffer *str, void *_dive)
struct dive *dive = _dive;
cylinder_t *cylinder = dive->cylinder + cylinder_index;
+ if (cylinder_index >= MAX_CYLINDERS)
+ return;
+
cylinder->type.description = get_utf8(str);
for (;;) {
char c;
@@ -423,6 +426,9 @@ static void parse_dive_weightsystem(char *line, struct membuffer *str, void *_di
struct dive *dive = _dive;
weightsystem_t *ws = dive->weightsystem + weightsystem_index;
+ if (weightsystem_index >= MAX_WEIGHTSYSTEMS)
+ return;
+
weightsystem_index++;
ws->description = get_utf8(str);
for (;;) {