[experimental-ims] 48392ad Fix crash in varnishadm when secret file is unreadable

Geoff Simmons geoff at varnish-cache.org
Fri Jul 8 11:47:33 CEST 2011


commit 48392ad84205195f8d624e281f3b93d7d736ce46
Author: Tollef Fog Heen <tfheen at varnish-software.com>
Date:   Thu Jun 9 08:51:13 2011 +0200

    Fix crash in varnishadm when secret file is unreadable
    
    Record the original strdup-ed value so we can free it afterwards.
    
    Fixes: #935

diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c
index baa4048..46273bc 100644
--- a/bin/varnishadm/varnishadm.c
+++ b/bin/varnishadm/varnishadm.c
@@ -274,7 +274,7 @@ usage(void)
 static int
 n_arg_sock(const char *n_arg)
 {
-	char *T_arg = NULL;
+	char *T_arg = NULL, *T_start = NULL;
 	char *S_arg = NULL;
 	struct VSM_data *vsd;
 	char *p;
@@ -292,7 +292,7 @@ n_arg_sock(const char *n_arg)
 			fprintf(stderr, "No -T arg in shared memory\n");
 			return (-1);
 		}
-		T_arg = strdup(p);
+		T_start = T_arg = strdup(p);
 	}
 	if (S_arg == NULL) {
 		p = VSM_Find_Chunk(vsd, "Arg", "-S", "", NULL);
@@ -309,7 +309,7 @@ n_arg_sock(const char *n_arg)
 			break;
 		T_arg = p + 1;
 	}
-	free(T_arg);
+	free(T_start);
 	free(S_arg);
 	return (sock);
 }



More information about the varnish-commit mailing list