Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

body for error message is created incorrectly in connectionDidFinishLoading #73

Open
jdberry opened this issue Jan 3, 2011 · 0 comments

Comments

@jdberry
Copy link

jdberry commented Jan 3, 2011

The body passed into the error message in the code > 400 case of connectionDidFinishLoading is calculated incorrectly: it uses stringWithUTF8String, which assumes a null-terminated string. Unfortunately, the NSData receivedData is not null-terminated, and so this can fail, in obvious or and/or dangerous ways. Instead of using stringWithUTF8String, you should used the NSString initWithData initializer, as below...

    NSString *body = [receivedData length] ? [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding] : @"";

There are a couple of other similar improper uses of stringWithUTF8String in the code, but they seem to be behind debug checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant