[master] bebe5e4 Coverity polishing.

Poul-Henning Kamp phk at FreeBSD.org
Mon May 30 23:17:05 CEST 2016


commit bebe5e407f5343a1d7897d68b1d3ea44addf3c83
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon May 30 21:14:52 2016 +0000

    Coverity polishing.

diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index dfc7235..055c841 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -833,7 +833,7 @@ ccf_config_label(struct cli *cli, const char * const *av, void *priv)
 	if (lbl == NULL) {
 		ALLOC_OBJ(lbl, VCL_MAGIC);
 		AN(lbl);
-		strcpy(lbl->state, VCL_TEMP_LABEL);
+		bprintf(lbl->state, "%s", VCL_TEMP_LABEL);
 		lbl->temp = VCL_TEMP_WARM;
 		lbl->loaded_name = strdup(av[2]);
 		AN(lbl->loaded_name);
diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c
index f30acf0..48f2a71 100644
--- a/bin/varnishtest/vtc_main.c
+++ b/bin/varnishtest/vtc_main.c
@@ -476,7 +476,7 @@ static int
 read_file(const char *fn, int ntest)
 {
 	struct vtc_tst *tp;
-	char *p;
+	char *p, *q;
 
 	p = VFIL_readfile(NULL, fn, NULL);
 	if (p == NULL) {
@@ -484,23 +484,24 @@ read_file(const char *fn, int ntest)
 		    fn, strerror(errno));
 		return (2);
 	}
-	for (;p != NULL && *p != '\0'; p++) {
-		if (vct_islws(*p))
+	for (q = p ;q != NULL && *q != '\0'; q++) {
+		if (vct_islws(*q))
 			continue;
-		if (*p != '#')
+		if (*q != '#')
 			break;
-		p = strchr(p, '\n');
+		q = strchr(q, '\n');
 	}
 
-	if (p == NULL || *p == '\0') {
+	if (q == NULL || *q == '\0') {
 		fprintf(stderr, "File \"%s\" has no content.\n", fn);
+		free(p);
 		return (2);
 	}
 
-	if (strncmp(p, "varnishtest", 11) || !isspace(p[11])) {
+	if (strncmp(q, "varnishtest", 11) || !isspace(q[11])) {
 		fprintf(stderr,
-		    "File \"%s\" doesn't start with 'varnishtest'\n",
-		    fn);
+		    "File \"%s\" doesn't start with 'varnishtest'\n", fn);
+		free(p);
 		return(2);
 	}
 	ALLOC_OBJ(tp, TST_MAGIC);



More information about the varnish-commit mailing list