From d36e9e431c072c06fcb850355dad921b51e2d780 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 24 Aug 2019 12:17:53 +0200 Subject: [PATCH] Avoid string truncation --- src/algorithms/libs/rtklib/rtklib_ionex.cc | 2 +- src/algorithms/libs/rtklib/rtklib_preceph.cc | 4 ++-- src/algorithms/libs/rtklib/rtklib_rtkcmn.cc | 2 +- src/algorithms/libs/rtklib/rtklib_sbas.cc | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/algorithms/libs/rtklib/rtklib_ionex.cc b/src/algorithms/libs/rtklib/rtklib_ionex.cc index 72f1528ff..94d641c13 100644 --- a/src/algorithms/libs/rtklib/rtklib_ionex.cc +++ b/src/algorithms/libs/rtklib/rtklib_ionex.cc @@ -463,7 +463,7 @@ void readtec(const char *file, nav_t *nav, int opt) } for (i = 0; i < MAXEXFILE; i++) { - if (!(efiles[i] = static_cast(malloc(1024)))) + if (!(efiles[i] = static_cast(malloc(MAXSTRPATH + 255)))) { for (i--; i >= 0; i--) { diff --git a/src/algorithms/libs/rtklib/rtklib_preceph.cc b/src/algorithms/libs/rtklib/rtklib_preceph.cc index 0b80640b7..bd26944b1 100644 --- a/src/algorithms/libs/rtklib/rtklib_preceph.cc +++ b/src/algorithms/libs/rtklib/rtklib_preceph.cc @@ -420,7 +420,7 @@ void readsp3(const char *file, nav_t *nav, int opt) for (i = 0; i < MAXEXFILE; i++) { - if (!(efiles[i] = static_cast(malloc(1024)))) + if (!(efiles[i] = static_cast(malloc(MAXSTRPATH + 255)))) { for (i--; i >= 0; i--) { @@ -601,7 +601,7 @@ int readdcb(const char *file, nav_t *nav, const sta_t *sta) } for (i = 0; i < MAXEXFILE; i++) { - if (!(efiles[i] = static_cast(malloc(1024)))) + if (!(efiles[i] = static_cast(malloc(MAXSTRPATH + 255)))) { for (i--; i >= 0; i--) { diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index efec6edeb..29b9d024e 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -5278,7 +5278,7 @@ int expath(const char *path, char *paths[], int nmax) } if (p && n < nmax) { - std::snprintf(paths[n++], MAXSTRPATH, "%s%s", dir, d->d_name); + std::snprintf(paths[n++], MAXSTRPATH + 255, "%s%s", dir, d->d_name); } } closedir(dp); diff --git a/src/algorithms/libs/rtklib/rtklib_sbas.cc b/src/algorithms/libs/rtklib/rtklib_sbas.cc index 3c239161e..7379a8fa5 100644 --- a/src/algorithms/libs/rtklib/rtklib_sbas.cc +++ b/src/algorithms/libs/rtklib/rtklib_sbas.cc @@ -782,7 +782,7 @@ int sbsreadmsgt(const char *file, int sel, gtime_t ts, gtime_t te, for (i = 0; i < MAXEXFILE; i++) { - if (!(efiles[i] = static_cast(malloc(1024)))) + if (!(efiles[i] = static_cast(malloc(MAXSTRPATH + 255)))) { for (i--; i >= 0; i--) {