From a0fb2d179d47ec528c102035b49ec7279aad9483 Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Tue, 30 Oct 2012 16:38:09 +0100 Subject: [PATCH] ERROR fix error string creation At some points in the code the error string includes itself. This generates self-repeating error messages. --- lib/init.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/init.c b/lib/init.c index b80456c..b01cba1 100644 --- a/lib/init.c +++ b/lib/init.c @@ -243,13 +243,15 @@ void iscsi_set_error(struct iscsi_context *iscsi, const char *error_string, ...) { va_list ap; + char errstr[MAX_STRING_SIZE+1] = {0}; va_start(ap, error_string); - if (vsnprintf(iscsi->error_string, MAX_STRING_SIZE, error_string, ap) < 0) { - strncpy(iscsi->error_string,"could not format error string!",MAX_STRING_SIZE); + if (vsnprintf(errstr, MAX_STRING_SIZE, error_string, ap) < 0) { + strncpy(errstr,"could not format error string!",MAX_STRING_SIZE); } va_end(ap); + strncpy(iscsi->error_string,errstr,MAX_STRING_SIZE); DPRINTF(iscsi,1,"%s",iscsi->error_string); }