From 8406455b4d94324a77e81f2fc14110f335c3d1f4 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 21 Feb 2017 15:47:43 +0100 Subject: [PATCH] ifcfg: drop strlen() call from svEscape() --- src/settings/plugins/ifcfg-rh/shvar.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c index 619a54afb8..a058657932 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.c +++ b/src/settings/plugins/ifcfg-rh/shvar.c @@ -220,14 +220,12 @@ svEscape (const char *s, char **to_free) int newlen; size_t i, j, slen; - slen = strlen (s); - - for (i = 0; i < slen; i++) { - if (_char_req_escape (s[i])) + for (slen = 0; s[slen]; slen++) { + if (_char_req_escape (s[slen])) mangle++; - else if (_char_req_quotes (s[i])) + else if (_char_req_quotes (s[slen])) requires_quotes = TRUE; - else if (s[i] < ' ') { + else if (s[slen] < ' ') { /* if the string contains newline we can only express it using ANSI C quotation * (as we don't support line continuation). * Additionally, ANSI control characters look odd with regular quotation, so handle