From 9c9dd9f06fa833bda1d1bb61984343747b6aaaef Mon Sep 17 00:00:00 2001 From: Dean Stevick Date: Sat, 23 Jun 2018 09:02:06 -0500 Subject: [PATCH] Fix multi-arg predicate processing Multi-arg predicates like "BETWEEN %@ AND %@" cause a crash in stringWithFormat since only one arg is given (i.e. "?,?"). The obvious intent was to supply two args "?" and "?". Provided a fix that determines the number of args and appends them one at a time. --- Incremental Store/.EncryptedStore.m.swp | Bin 0 -> 16384 bytes Incremental Store/EncryptedStore.m | 11 +++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 Incremental Store/.EncryptedStore.m.swp diff --git a/Incremental Store/.EncryptedStore.m.swp b/Incremental Store/.EncryptedStore.m.swp new file mode 100644 index 0000000000000000000000000000000000000000..07c7b634d0d96e5fe7c34d8d74729760c577c90d GIT binary patch literal 16384 zcmeHNUyvL{8J~c`paC=%1t^xCOIhr0F1vS0h}0#7yW6{%OLBMNE(yUS+04%L?oMuZ zW-`-rWQlwi-n*f%lBZYd6Ec;2OHN46K|zIXHM+GVw6n#pxrCNK4v zzTgX%F<&%m`rVENtp#Q3usy(YU^&fO53o0FdXV@`c|{|tlFDd zCbK|hfy@G#1u_d{7RW4+Ss=4OW`X}B3kY|Uc0byC8MV1izsr>0f6{Z5(i;l@58`)I z`U?twj`)3)K0p=3^}I>^?Zh8f_&10jA^vHF|2y$B#9vPhisk=}_$lHKEBx!kmx=#| z!vB@{L&U$K@P8qG2k~>4M=x>xeuLkj-~ z;tvwPYI(Z+?}?u#-c|VD5kE=%BMSd2@gE_6CQ75=Bh$L)Ln%C!7vi65o%hZX)A;^X!|sPI1_J{~_S zu1d>)n)q3gUs3oU6Cc~>s|x=V@v(njesx;@lf-k9zhB{hMErK*A6ED$h~Gy1@@vxa zA18hz@jDg%hs19o{(go30r7GCeMsTIPkbEz-c!b!8_t^L6UWC>#Jf?l_Bn;8 zaHw5J{K|JnFL8NF&VDirWERLQkXazJKxTo=0+|Jtuz+rA+O^2@m|RF<%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Na%7^EVcUEFM|DXopI61Ooxv?EnaMF z?G_^OQEs`%scCDtG(OuS*DK*B0Ta)W01Gvrjm(sbC|hHzD-}#al^P;&;PIRkU%^@k zp|e!NKPF?oXVn{mtsfX%j}VHVjS$J%V z0_K1lfRAEdzZKX7d=OXz^Z~M-8-eV}ERb0svp{Bn%mSGOG7DrD$Sjaq;J?fQ(P?$+ zUdP0Fcyz)j?^EOnqkQBU`|9X)9s4-!ba0l2-Jw4no(c}l^ES@gWzjkLicK2!I8o{7 z`ov3|YSTF~<2Zc6nXr&MLx04k!$yCvkK?b=ren+x9mIiIeA&e+Q;uy1*!-Y|3m%kr zb3%!JHab1Mixs+wzHnT5Hz1pZgU$fgUrij&bZ-GiTi+L&;GA;w`!M5*Vi2j#TGxN{R=bf Bga-fs literal 0 HcmV?d00001 diff --git a/Incremental Store/EncryptedStore.m b/Incremental Store/EncryptedStore.m index aa7a382..e10b7fa 100755 --- a/Incremental Store/EncryptedStore.m +++ b/Incremental Store/EncryptedStore.m @@ -4189,8 +4189,15 @@ - (void)parseExpression:(NSExpression *)expression if (exprBinding) [*bindings addObject:exprBinding]; } - *operand = [NSString stringWithFormat:[operator objectForKey:@"format"], - [subOperands componentsJoinedByString:@","]]; + NSString *strFormat = [operator objectForKey:@"format"]; + NSMutableString *strOperands = [NSMutableString string]; + // Courtesy of Ruslan Soldatenko at https://stackoverflow.com/a/40638476 + NSArray *arrComponents = strFormat ? [strFormat componentsSeparatedByString:@"%@"] : @[@""]; + NSUInteger iterationCount = subOperands.count < arrComponents.count ? subOperands.count : arrComponents.count; + for ( NSUInteger i = 0; i < iterationCount; i++ ) + [strOperands appendFormat:@"%@%@", arrComponents[i], subOperands[i]]; + [strOperands appendString:[arrComponents lastObject]]; + *operand = iterationCount == 0 ? [strOperands stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] : strOperands; *bindings = [*bindings cmdFlatten]; }