From efc6082722613176c7a9d454e84cf0e126a0fb05 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 7 Jun 2017 12:11:16 +0200 Subject: [PATCH] Fix defects detected by coverity scan --- src/algorithms/libs/rtklib/rtklib_ionex.cc | 16 ++++++++------- src/algorithms/libs/rtklib/rtklib_ppp.cc | 3 ++- src/algorithms/libs/rtklib/rtklib_preceph.cc | 6 +++++- src/algorithms/libs/rtklib/rtklib_rtkcmn.cc | 21 +++++++++++++------- src/algorithms/libs/rtklib/rtklib_rtkpos.cc | 3 ++- src/algorithms/libs/rtklib/rtklib_sbas.cc | 2 +- 6 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/algorithms/libs/rtklib/rtklib_ionex.cc b/src/algorithms/libs/rtklib/rtklib_ionex.cc index 404cd34f9..ced43801f 100644 --- a/src/algorithms/libs/rtklib/rtklib_ionex.cc +++ b/src/algorithms/libs/rtklib/rtklib_ionex.cc @@ -394,15 +394,17 @@ void readtec(const char *file, nav_t *nav, int opt) trace(2, "ionex file open error %s\n", efiles[i]); continue; } - /* read ionex header */ - if (readionexh(fp, lats, lons, hgts, &rb, &nexp, dcb, rms) <= 0.0) + else { - trace(2, "ionex file format error %s\n", efiles[i]); - continue; + /* read ionex header */ + if (readionexh(fp, lats, lons, hgts, &rb, &nexp, dcb, rms) <= 0.0) + { + trace(2, "ionex file format error %s\n", efiles[i]); + continue; + } + /* read ionex body */ + readionexb(fp, lats, lons, hgts, rb, nexp, nav); } - /* read ionex body */ - readionexb(fp, lats, lons, hgts, rb, nexp, nav); - fclose(fp); } for (i = 0; i < MAXEXFILE; i++) free(efiles[i]); diff --git a/src/algorithms/libs/rtklib/rtklib_ppp.cc b/src/algorithms/libs/rtklib/rtklib_ppp.cc index 2b606f07e..96ccb7237 100644 --- a/src/algorithms/libs/rtklib/rtklib_ppp.cc +++ b/src/algorithms/libs/rtklib/rtklib_ppp.cc @@ -490,6 +490,7 @@ int fix_amb_ILS(rtk_t *rtk, int *sat1, int *sat2, int *NW, int n) if (rtk->opt.thresar[0]>0.0 && rtk->sol.ratioopt.thresar[0]) { trace(2, "varidation error: n=%2d ratio=%8.3f\n", m, rtk->sol.ratio); + free(B1); free(N1); free(D); free(E); free(Q); free(NC); return 0; } trace(2, "varidation ok: %s n=%2d ratio=%8.3f\n", time_str(rtk->sol.time, 0), m, @@ -898,7 +899,7 @@ void testeclipse(const obsd_t *obs, int n, const nav_t *nav, double *rs) /* unit vector of sun direction (ecef) */ sunmoonpos(gpst2utc(obs[0].time), erpv, rsun, NULL, NULL); - normv3(rsun, esun); + if(normv3(rsun, esun) == 0) trace(1, "Error computing the norm"); for (i = 0;i0) { if(strlen(paths[i]) < 1025) strcpy(tmp, paths[i]); + else + { + trace(1, "Path is too long"); + } strcpy(paths[i], paths[j]); strcpy(paths[j], tmp); } diff --git a/src/algorithms/libs/rtklib/rtklib_rtkpos.cc b/src/algorithms/libs/rtklib/rtklib_rtkpos.cc index 437b75e1f..2ced73641 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkpos.cc @@ -156,7 +156,8 @@ int rtkopenstat(const char *file, int level) trace(1, "rtkopenstat: file open error path=%s\n", path); return 0; } - strcpy(file_stat, file); + if(strlen(file) < 1025) strcpy(file_stat, file); + else trace(1, "File name is too long"); time_stat = time; statlevel = level; return 1; diff --git a/src/algorithms/libs/rtklib/rtklib_sbas.cc b/src/algorithms/libs/rtklib/rtklib_sbas.cc index ad081128f..6cddfce3c 100644 --- a/src/algorithms/libs/rtklib/rtklib_sbas.cc +++ b/src/algorithms/libs/rtklib/rtklib_sbas.cc @@ -536,7 +536,7 @@ void readmsgs(const char *file, int sel, gtime_t ts, gtime_t te, if (!(sbs_msgs = (sbsmsg_t *)realloc(sbs->msgs, sbs->nmax * sizeof(sbsmsg_t)))) { trace(1, "readsbsmsg malloc error: nmax=%d\n", sbs->nmax); - free(sbs->msgs); sbs->msgs = NULL; sbs->n = sbs->nmax = 0; + free(sbs->msgs); sbs->msgs = NULL; sbs->n = sbs->nmax = 0; fclose(fp); return; } sbs->msgs = sbs_msgs;