Fix defects detected by coverity scan

This commit is contained in:
Carles Fernandez 2017-06-07 12:11:16 +02:00
parent 0047595373
commit efc6082722
6 changed files with 33 additions and 18 deletions

View File

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

View File

@ -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.ratio<rtk->opt.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;i<n;i++)
{

View File

@ -530,7 +530,11 @@ int readfcbf(const char *file, nav_t *nav)
if (!(sat = satid2no(str))) continue;
ts = epoch2time(ep1);
te = epoch2time(ep2);
if (!addfcb(nav, ts, te, sat, bias, std)) return 0;
if (!addfcb(nav, ts, te, sat, bias, std))
{
fclose(fp);
return 0;
}
}
fclose(fp);
return 1;

View File

@ -2194,7 +2194,7 @@ int readantex(const char *file, pcvs_t *pcvs)
{
FILE *fp;
static const pcv_t pcv0 = {0, {}, {}, {0,0}, {0,0}, {{},{}}, {{},{}} };
pcv_t pcv;
pcv_t pcv = {0, {}, {}, {0,0}, {0,0}, {{},{}}, {{},{}} };
double neu[3];
int i, f, freq = 0, state = 0, freqs[] = {1, 2, 5, 6, 7, 8, 0};
char buff[256];
@ -2324,7 +2324,7 @@ pcv_t *searchpcv(int sat, const char *type, gtime_t time,
const pcvs_t *pcvs)
{
pcv_t *pcv;
char buff[MAXANT], *types[2], *p;
char buff[MAXANT] = "", *types[2], *p;
int i, j, n = 0;
trace(3, "searchpcv: sat=%2d type=%s\n", sat, type);
@ -2343,7 +2343,10 @@ pcv_t *searchpcv(int sat, const char *type, gtime_t time,
else
{
if(strlen(type) < MAXANT +1 ) strcpy(buff, type);
else trace(1, "type array is too long");
else
{
trace(1, "type array is too long");
}
for (p = strtok(buff, " "); p && n<2; p = strtok(NULL, " ")) types[n++] = p;
if (n <= 0) return NULL;
@ -3961,10 +3964,10 @@ int rtk_uncompress(const char *file, char *uncfile)
if (execcmd(cmd))
{
remove(uncfile);
if(remove(uncfile) != 0) trace(1, "Error removing file");
return -1;
}
strcpy(tmpfile, uncfile);
if(strlen(uncfile) < 1025) strcpy(tmpfile, uncfile);
stat = 1;
}
/* extract tar file */
@ -3996,7 +3999,7 @@ int rtk_uncompress(const char *file, char *uncfile)
if (execcmd(cmd))
{
remove(uncfile);
if(remove(uncfile) != 0) trace(1, "Error removing file");
if (stat) if(remove(tmpfile) != 0) trace(1, "Error removing file");
return -1;
}
@ -4019,7 +4022,7 @@ int rtk_uncompress(const char *file, char *uncfile)
int expath(const char *path, char *paths[], int nmax)
{
int i, j, n = 0;
char tmp[1024];
char tmp[1024] = "";
struct dirent *d;
DIR *dp;
const char *file = path;
@ -4055,6 +4058,10 @@ int expath(const char *path, char *paths[], int nmax)
if (strcmp(paths[i], paths[j])>0)
{
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);
}

View File

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

View File

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