Re: Mac OS X 10.5.8 update breaks tokenize function in -[NSXMLNode objectsForXQuery:error:]

2009-08-06 Thread Michael Link
After some more investigation I've discovered that XQuery was updated  
in Mac OS X 10.5.8 as part of a security vulnerability in the PCRE  
library which it includes.


http://support.apple.com/kb/HT3757 (scroll to bottom of page)

Which also explains why all XQuery functions using regular expressions  
are also broken. Digging into the PCRE portion of the XQuery code  
reveals the following PCRE error string after trying to compile a  
regular expression:


this version of PCRE is not compiled with PCRE_UTF8 support

#0  0x0010f430 in pcre_compile
#1  0x00100495 in -[XQueryRegEx initExpr:withFlags:]
#2  0x000ff944 in +[XQueryRegEx regExp:withFlags:]
#3  0x000ce8e3 in fn_tokenize
#4  0x000db9cd in -[XQueryFunctionCall evaluateWithContext:]
#5  0x000f62b5 in -[XQueryExprList evaluateWithContext:]
#6	0x00102a9a in -[XQueryContext  
evaluateXQuery:constants:contextItem:error:]

#7  0x92201d98 in -[NSXMLNode objectsForXQuery:constants:error:]
#8  0x92303338 in -[NSXMLNode objectsForXQuery:error:]
#9  0x1d04 in -[Bug7037807 performXQuery:] at Bug7037807.m:40
#10 0x1c15 in -[Bug7037807 awakeFromNib] at Bug7037807.m:27
#11 0x9310f7f5 in -[NSSet makeObjectsPerformSelector:]
#12	0x910d2d8e in -[NSIBObjectData  
nibInstantiateWithOwner:topLevelObjects:]

#13 0x910c8fba in loadNib
#14	0x910c891c in +[NSBundle(NSNibLoading)  
_loadNibFile:nameTable:withZone:ownerBundle:]
#15	0x910c855f in +[NSBundle(NSNibLoading)  
loadNibFile:externalNameTable:withZone:]

#16 0x910c849d in +[NSBundle(NSNibLoading) loadNibNamed:owner:]
#17 0x910c814c in NSApplicationMain
#18 0x1ae8 in main at main.m:13

Dump of assembler code for function pcre_compile:
0x0010f3fb pcre_compile+0:  push   %ebp
0x0010f3fc pcre_compile+1:  mov%esp,%ebp
0x0010f3fe pcre_compile+3:  sub$0x28,%esp
0x0010f401 pcre_compile+6:  mov0x18(%ebp),%eax
0x0010f404 pcre_compile+9:  movl   $0x0,0x8(%esp)
0x0010f40c pcre_compile+17: mov%eax,0x14(%esp)
0x0010f410 pcre_compile+21: mov0x14(%ebp),%eax
0x0010f413 pcre_compile+24: mov%eax,0x10(%esp)
0x0010f417 pcre_compile+28: mov0x10(%ebp),%eax
0x0010f41a pcre_compile+31: mov%eax,0xc(%esp)
0x0010f41e pcre_compile+35: mov0xc(%ebp),%eax
0x0010f421 pcre_compile+38: mov%eax,0x4(%esp)
0x0010f425 pcre_compile+42: mov0x8(%ebp),%eax
0x0010f428 pcre_compile+45: mov%eax,(%esp)
0x0010f42b pcre_compile+48: call   0x10eb91 pcre_compile2
0x0010f430 pcre_compile+53: leave
0x0010f431 pcre_compile+54: ret
End of assembler dump.
(gdb) x/i $eip
0x10f430 pcre_compile+53:   leave

(gdb) p *(int*)($ebp + 16)
$26 = -1073745996
(gdb) p *$26
$27 = 1254561
(gdb) x/s $27
0x1324a1 error_texts+1033:	 this version of PCRE is not compiled  
with PCRE_UTF8 support


Did someone forget to turn on a compile flag?

--
Michael
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Mac OS X 10.5.8 update breaks tokenize function in -[NSXMLNode objectsForXQuery:error:]

2009-08-05 Thread Michael Link
I noticed that the recent update of Mac OS X 10.5.8 breaks  
compatibility with previous versions regarding XQuery statements in  
NSXMLNode, specifically using the XQuery function tokenize. I  
originally reported this bug against a future version of Mac OS X and  
now seems to have slipped into the latest update of Mac OS X 10.5.


rdar://problem/7037807

The following code works on Mac OS X 10.5.0 - 10.5.7 but does not work  
on Mac OS X 10.5.8.


@interface Bug7037807 : NSObject
{
NSXMLDocument* _document;
}
- (void)performXQuery:(NSString*)query;
@end

@implementation Bug7037807

- (id)init
{
if (self = [super init]) {
		_document = [[NSXMLDocument alloc]  
initWithXMLString:@htmltitletitle/titlebodyh1header/ 
h1pastring, bstring, cstring, dstring, estring/ppastring   
bstring  cstring  dstring  estring/p/body/html  
options:NSXMLDocumentTidyHTML error:nil];

}

return self;
}

- (void)awakeFromNib
{
[self performXQuery:@/descendant-or-self::p[1]];
[self performXQuery:@xs:string(/descendant-or-self::p[1])];
	[self performXQuery:@tokenize(xs:string(/descendant-or-self::p[1]),  
',')];

}

- (void)performXQuery:(NSString*)query
{
NSError* __error = nil;
NSArray* __results;

__results = [_document objectsForXQuery:query error:__error];

if (!__results) {
NSLog(@error: %@, __error);
}
else {
NSLog(@results: %@, __results);
}
}

@end


Output on Mac OS X 10.5.0 - 10.5.7

2009-08-05 23:34:49.428 Bug7037807[577:10b] results: (
pastring, bstring, cstring, dstring, estring
/p
)
2009-08-05 23:34:49.431 Bug7037807[577:10b] results: (
astring, bstring, cstring, dstring, estring\n
)
2009-08-05 23:34:49.432 Bug7037807[577:10b] results: (
astring,
 bstring,
 cstring,
 dstring,
 estring\n
)



Output on Mac OS X 10.5.8

2009-08-05 23:34:49.428 Bug7037807[577:10b] results: (
pastring, bstring, cstring, dstring, estring
/p
)
2009-08-05 23:34:49.431 Bug7037807[577:10b] results: (
astring, bstring, cstring, dstring, estring\n
)
2009-08-05 23:34:49.432 Bug7037807[577:10b] error: XQueryError:17 -  
invalid arguments to function - tokenize


What does the 10.5.8 version of tokenize want as arguments? Any known  
work-around?


--
Michael

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com