From 2382fed763493ec9182cb414bfc73076c74935bb Mon Sep 17 00:00:00 2001 From: Richard Frith-Macdonald Date: Mon, 25 Jan 2021 12:10:25 +0000 Subject: [PATCH] Fix check for string terminator and improve formatting --- Tools/plutil.m | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/Tools/plutil.m b/Tools/plutil.m index 80e7e27ab..f6d69df7d 100644 --- a/Tools/plutil.m +++ b/Tools/plutil.m @@ -190,22 +190,29 @@ parseQuotedString(const char *keypath, size_t *i) // Select the part of the quoted string that looks like a plist string for (end = begin + 1; *end && *end != '"'; end++) - if (*end == '\\') - { - if (end[1]) - end += 1; - else - [NSException raise: NSInvalidArgumentException - format: @"Premature EOF in keypath"]; - } - - if (!end) - [NSException raise: NSInvalidArgumentException - format: @"Premature EOF in keypath"]; + { + if (*end == '\\') + { + if (end[1]) + { + end += 1; + } + else + { + [NSException raise: NSInvalidArgumentException + format: @"Premature EOF in keypath"]; + } + } + } + if (!*end) + { + [NSException raise: NSInvalidArgumentException + format: @"Premature EOF in keypath"]; + } *i = end - keypath + 1; - parsed = [[NSString stringWithCString: begin length: end - begin] propertyList]; - return (NSString *) parsed; + parsed = [[NSString stringWithCString: begin length: end-begin] propertyList]; + return (NSString *)parsed; } /**