Re: NSTask Leaking...

2009-01-30 Thread Rob Keniger

On 30/01/2009, at 11:02 PM, Kirk Kerekes wrote:


Sorry about that...





Thanks, it works now. I had to modify the CryptoSample code and  
convert a bunch of uint32 types to CSSM_SIZE, but it compiles fine.

--
Rob Keniger



___

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


Re: NSTask Leaking...

2009-01-30 Thread Kirk Kerekes


Sorry about that...

<http://developer.apple.com/samplecode/CryptoSample/index.html>


Message: 4
Date: Fri, 30 Jan 2009 12:29:00 +1000
From: Rob Keniger 
Subject: Re: NSTask Leaking...
To: cocoadev cocoadev 
Message-ID: <958a5c01-246b-4255-b789-7fd5b257c...@menumachine.com>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

This code won't compile for me. Where is the referenced libCdsaCrypt.h
file?
--
Rob Keniger

On 30/01/2009, at 10:50 AM, Kirk Kerekes wrote:


// must include Security framework to use this
// Tiger or later for SHA256




___

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


Re: NSTask Leaking...

2009-01-29 Thread Mr. Gecko

Thanks for the help, I've got it working

On Jan 29, 2009, at 6:50 PM, Kirk Kerekes wrote:


// must include Security framework to use this
// Tiger or later for SHA256


#import "libCdsaCrypt.h"

@implementation NSData (DataDigest)

- (NSData *) digestWithCDSAType:(CSSM_ALGORITHMS) algorithm
{ // does not validate algorithm selection, let the framework worry  
about that.

NSData * result = nil;
int error = noErr;
CSSM_DATA inData;
CSSM_CSP_HANDLE cspHandle;
CSSM_DATA digestData;

error = cdsaCspAttach(&cspHandle);
if(!error)
{
inData.Data = (void *)[self bytes];
inData.Length = [self length];
/* calculate digest */
error = cdsaDigest(cspHandle, algorithm, &inData, &digestData);
if(!error)
{
			result = [NSData dataWithBytesNoCopy: digestData.Data length:  
digestData.Length freeWhenDone: YES];

}
}
return result;
}

- (NSData *) md5Digest
{
return [self digestWithCDSAType: CSSM_ALGID_MD5];
}

- (NSData *) sha1Digest
{
return [self digestWithCDSAType: CSSM_ALGID_SHA1];
}

#ifndef CSSM_ALGID_SHA256
#define CSSM_ALGID_SHA256 0
#endif

- (NSData *) sha256Digest
{
return [self digestWithCDSAType: CSSM_ALGID_SHA256];
}



@end



___

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


Re: NSTask Leaking...

2009-01-29 Thread Rob Keniger
This code won't compile for me. Where is the referenced libCdsaCrypt.h  
file?

--
Rob Keniger

On 30/01/2009, at 10:50 AM, Kirk Kerekes wrote:


// must include Security framework to use this
// Tiger or later for SHA256


#import "libCdsaCrypt.h"

@implementation NSData (DataDigest)

- (NSData *) digestWithCDSAType:(CSSM_ALGORITHMS) algorithm
{ // does not validate algorithm selection, let the framework worry  
about that.

NSData * result = nil;
int error = noErr;
CSSM_DATA inData;
CSSM_CSP_HANDLE cspHandle;
CSSM_DATA digestData;

error = cdsaCspAttach(&cspHandle);
if(!error)
{
inData.Data = (void *)[self bytes];
inData.Length = [self length];
/* calculate digest */
error = cdsaDigest(cspHandle, algorithm, &inData, &digestData);
if(!error)
{
			result = [NSData dataWithBytesNoCopy: digestData.Data length:  
digestData.Length freeWhenDone: YES];

}
}
return result;
}

- (NSData *) md5Digest
{
return [self digestWithCDSAType: CSSM_ALGID_MD5];
}

- (NSData *) sha1Digest
{
return [self digestWithCDSAType: CSSM_ALGID_SHA1];
}

#ifndef CSSM_ALGID_SHA256
#define CSSM_ALGID_SHA256 0
#endif

- (NSData *) sha256Digest
{
return [self digestWithCDSAType: CSSM_ALGID_SHA256];
}



@end





___

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


Re: NSTask Leaking...

2009-01-29 Thread Kirk Kerekes

// must include Security framework to use this
// Tiger or later for SHA256


#import "libCdsaCrypt.h"

@implementation NSData (DataDigest)

- (NSData *) digestWithCDSAType:(CSSM_ALGORITHMS) algorithm
{ // does not validate algorithm selection, let the framework worry  
about that.

NSData * result = nil;
int error = noErr;
CSSM_DATA inData;
CSSM_CSP_HANDLE cspHandle;
CSSM_DATA digestData;

error = cdsaCspAttach(&cspHandle);
if(!error)
{
inData.Data = (void *)[self bytes];
inData.Length = [self length];
/* calculate digest */
error = cdsaDigest(cspHandle, algorithm, &inData, &digestData);
if(!error)
{
			result = [NSData dataWithBytesNoCopy: digestData.Data length:  
digestData.Length freeWhenDone: YES];

}
}
return result;
}

- (NSData *) md5Digest
{
return [self digestWithCDSAType: CSSM_ALGID_MD5];
}

- (NSData *) sha1Digest
{
return [self digestWithCDSAType: CSSM_ALGID_SHA1];
}

#ifndef CSSM_ALGID_SHA256
#define CSSM_ALGID_SHA256 0
#endif

- (NSData *) sha256Digest
{
return [self digestWithCDSAType: CSSM_ALGID_SHA256];
}



@end

___

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


Re: NSTask Leaking...

2009-01-29 Thread Jean-Daniel Dupas


unsigned char digest[CC_MD5_DIGEST_LENGTH];
if (CC_MD5([fileData bytes], [fileData length], digest)) {
  // md5 stored in digest.
} else {
 // handle error
}

And if you file is to big to be hash at once, use whatever you want to  
read it one by chunks.


char buffer[1024];
CC_MD5_CTX ctxt;
CC_MD5_Init(&ctxt);
while ((length = read(fd, buffer, 1024)) > 0) {
CC_MD5_Update(&ctxt, buffer, length);
}
CC_MD5_Final(digest, &ctxt);

You probably want better error checking but this is the main idea.

Le 29 janv. 09 à 23:06, Mr. Gecko a écrit :

but for an example, How would I implement it? is there any example  
applications out there?


On Jan 29, 2009, at 3:35 PM, Jean-Daniel Dupas wrote:



Le 29 janv. 09 à 22:20, Jeremy Pereira a écrit :



On 29 Jan 2009, at 19:33, Mr. Gecko wrote:


I'm just going to use sscrypto framework for it...


If a malicious person can replace an executable with his own, he  
can probably also replace a framework...




Why using a library when the libSystem provide hash functionality ?

/usr/include/CommonCrypto/CommonDigest.h







Regardless of any other problems, you've introduced a serious  
weakness - a hacker just needs to temporarily change /sbin/md5  
to a shell script that cats the expected output.  For that  
matter, they could easily edit the binary to change the string "/ 
sbin/md5" to another path that does the deed (to avoid having to  
mess with sbin each time)


If you are trying to write secure code, don't execute external  
binaries that you have no control over and expect it to be secure.



Glenn Andreas  gandr...@gandreas.com
 wicked fun!
JSXObjC | the easy way to unite JavaScript and Objective C






___

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/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

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/devlists%40shadowlab.org

This email sent to devli...@shadowlab.org








___

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


Re: NSTask Leaking...

2009-01-29 Thread Mr. Gecko
but for an example, How would I implement it? is there any example  
applications out there?


On Jan 29, 2009, at 3:35 PM, Jean-Daniel Dupas wrote:



Le 29 janv. 09 à 22:20, Jeremy Pereira a écrit :



On 29 Jan 2009, at 19:33, Mr. Gecko wrote:


I'm just going to use sscrypto framework for it...


If a malicious person can replace an executable with his own, he  
can probably also replace a framework...




Why using a library when the libSystem provide hash functionality ?

/usr/include/CommonCrypto/CommonDigest.h







Regardless of any other problems, you've introduced a serious  
weakness - a hacker just needs to temporarily change /sbin/md5 to  
a shell script that cats the expected output.  For that matter,  
they could easily edit the binary to change the string "/sbin/ 
md5" to another path that does the deed (to avoid having to mess  
with sbin each time)


If you are trying to write secure code, don't execute external  
binaries that you have no control over and expect it to be secure.



Glenn Andreas  gandr...@gandreas.com
 wicked fun!
JSXObjC | the easy way to unite JavaScript and Objective C






___

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/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

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/devlists%40shadowlab.org

This email sent to devli...@shadowlab.org





___

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


Re: NSTask Leaking...

2009-01-29 Thread Mr. Gecko

not if I take the parts for MD5 and place it in my own binary.

On Jan 29, 2009, at 3:19 PM, Jeremy Pereira wrote:



On 29 Jan 2009, at 19:33, Mr. Gecko wrote:


I'm just going to use sscrypto framework for it...


If a malicious person can replace an executable with his own, he can  
probably also replace a framework...






Regardless of any other problems, you've introduced a serious  
weakness - a hacker just needs to temporarily change /sbin/md5 to  
a shell script that cats the expected output.  For that matter,  
they could easily edit the binary to change the string "/sbin/md5"  
to another path that does the deed (to avoid having to mess with  
sbin each time)


If you are trying to write secure code, don't execute external  
binaries that you have no control over and expect it to be secure.



Glenn Andreas  gandr...@gandreas.com
 wicked fun!
JSXObjC | the easy way to unite JavaScript and Objective C






___

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/adc%40jeremyp.net

This email sent to a...@jeremyp.net




___

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


Re: NSTask Leaking...

2009-01-29 Thread Jean-Daniel Dupas


Le 29 janv. 09 à 22:20, Jeremy Pereira a écrit :



On 29 Jan 2009, at 19:33, Mr. Gecko wrote:


I'm just going to use sscrypto framework for it...


If a malicious person can replace an executable with his own, he can  
probably also replace a framework...




Why using a library when the libSystem provide hash functionality ?

/usr/include/CommonCrypto/CommonDigest.h







Regardless of any other problems, you've introduced a serious  
weakness - a hacker just needs to temporarily change /sbin/md5 to  
a shell script that cats the expected output.  For that matter,  
they could easily edit the binary to change the string "/sbin/md5"  
to another path that does the deed (to avoid having to mess with  
sbin each time)


If you are trying to write secure code, don't execute external  
binaries that you have no control over and expect it to be secure.



Glenn Andreas  gandr...@gandreas.com
 wicked fun!
JSXObjC | the easy way to unite JavaScript and Objective C






___

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/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

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/devlists%40shadowlab.org

This email sent to devli...@shadowlab.org



___

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


Re: NSTask Leaking...

2009-01-29 Thread Chris Suter
Hi Mr Gecko,

On Fri, Jan 30, 2009 at 6:33 AM, Mr. Gecko  wrote:
> I'm just going to use sscrypto framework for it...

You don't need to use a third party framework for crypto stuff.

There are common hashing functions built in to libSystem. Look at the
CC_crypto man page.

If you need other crypto functions not provided by libSystem, you can
use libcrypto.

Regards,

Chris
___

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


Re: NSTask Leaking...

2009-01-29 Thread Jeremy Pereira


On 29 Jan 2009, at 19:33, Mr. Gecko wrote:


I'm just going to use sscrypto framework for it...


If a malicious person can replace an executable with his own, he can  
probably also replace a framework...






Regardless of any other problems, you've introduced a serious  
weakness - a hacker just needs to temporarily change /sbin/md5 to a  
shell script that cats the expected output.  For that matter, they  
could easily edit the binary to change the string "/sbin/md5" to  
another path that does the deed (to avoid having to mess with sbin  
each time)


If you are trying to write secure code, don't execute external  
binaries that you have no control over and expect it to be secure.



Glenn Andreas  gandr...@gandreas.com
 wicked fun!
JSXObjC | the easy way to unite JavaScript and Objective C






___

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/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

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


Re: NSTask Leaking...

2009-01-29 Thread Mr. Gecko

I'm just going to use sscrypto framework for it...

On Jan 29, 2009, at 12:39 PM, glenn andreas wrote:



On Jan 29, 2009, at 12:20 PM, Mr. Gecko wrote:

Hello, I'm trying to make my own licenses system and I need MD5 to  
verify that the key in the file is right and isn't a fake.
what I've got now is a NSTask that runs md5 -s salt+key+salt2 and  
it works, but I am getting a leak with NSTask...



Regardless of any other problems, you've introduced a serious  
weakness - a hacker just needs to temporarily change /sbin/md5 to a  
shell script that cats the expected output.  For that matter, they  
could easily edit the binary to change the string "/sbin/md5" to  
another path that does the deed (to avoid having to mess with sbin  
each time)


If you are trying to write secure code, don't execute external  
binaries that you have no control over and expect it to be secure.



Glenn Andreas  gandr...@gandreas.com
 wicked fun!
JSXObjC | the easy way to unite JavaScript and Objective C






___

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


Re: NSTask Leaking...

2009-01-29 Thread glenn andreas


On Jan 29, 2009, at 12:20 PM, Mr. Gecko wrote:

Hello, I'm trying to make my own licenses system and I need MD5 to  
verify that the key in the file is right and isn't a fake.
what I've got now is a NSTask that runs md5 -s salt+key+salt2 and it  
works, but I am getting a leak with NSTask...



Regardless of any other problems, you've introduced a serious weakness  
- a hacker just needs to temporarily change /sbin/md5 to a shell  
script that cats the expected output.  For that matter, they could  
easily edit the binary to change the string "/sbin/md5" to another  
path that does the deed (to avoid having to mess with sbin each time)


If you are trying to write secure code, don't execute external  
binaries that you have no control over and expect it to be secure.



Glenn Andreas  gandr...@gandreas.com
  wicked fun!
JSXObjC | the easy way to unite JavaScript and Objective C




___

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


Re: NSTask Leaking...

2009-01-29 Thread Vitaly Ovchinnikov
At least one leak is here:
>NSString *rMD5 = NSString alloc] initWithData:.];

You just put new string object to rMD5 and now need to release it.

>...
>rMD5 = [self replace:@"\n" with:@"" source:rMD5];

You just created another string object that you don't need to release,
and replace pointer to the first string with the new string

>...
>return [rMD5 autorelease];

And here you asked for autorelease of the object that you don't need to release.
___

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


Re: NSTask Leaking...

2009-01-29 Thread Nick Zitzmann


On Jan 29, 2009, at 12:20 PM, Mr. Gecko wrote:

	[theTask setArguments:[[NSArray arrayWithObjects:@"-s", MD5, nil]  
autorelease]];


This is incorrect and should be causing a crash, unless you're using  
GC. +arrayWithObjects: already returns an autoreleased object.


	NSString *rMD5 = NSString alloc] initWithData:[[outPipe  
fileHandleForReading] readDataToEndOfFile] encoding:  
NSUTF8StringEncoding] componentsSeparatedByString:@" = "]  
objectAtIndex:1];


Your memory leak is right here. The result of -initWithData: needs to  
be autoreleased. But I'd also recommend breaking up that line to be  
easier to read...



rMD5 = [self replace:@"\n" with:@"" source:rMD5];

return [rMD5 autorelease];



If your replace method isn't returning an autoreleased object, it  
should be. Don't break with conventions.


Also, if you want to hash something, then you should probably use the  
functions in libcrypto instead of using NSTask. That'll at least be  
faster...


Nick Zitzmann




___

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


Re: NSTask Leaking...

2009-01-29 Thread Stephen J. Butler
On Thu, Jan 29, 2009 at 12:20 PM, Mr. Gecko  wrote:
>[theTask setStandardOutput:[outPipe autorelease]];

The autorelease here is wrong...

>[theTask setLaunchPath:@"/sbin/md5"];
>[theTask setCurrentDirectoryPath:@"~/"];
>[theTask setArguments:[[NSArray arrayWithObjects:@"-s", MD5, nil]
> autorelease]];

Along with here...

>[theTask launch];
>[theTask waitUntilExit];
>NSString *rMD5 = NSString alloc] initWithData:[[outPipe
> fileHandleForReading] readDataToEndOfFile] encoding: NSUTF8StringEncoding]
> componentsSeparatedByString:@" = "] objectAtIndex:1];
>[theTask release];
>
>rMD5 = [self replace:@"\n" with:@"" source:rMD5];
>
>return [rMD5 autorelease];

And here. Maybe. I don't know what your replace:with:source method does.

But there are better ways to get the MD5 of some data:


___

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


Re: NSTask Leaking...

2009-01-29 Thread Mr. Gecko

I forgot to tell that the releasing of NSTask is crashing it...
___

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


NSTask Leaking...

2009-01-29 Thread Mr. Gecko
Hello, I'm trying to make my own licenses system and I need MD5 to  
verify that the key in the file is right and isn't a fake.
what I've got now is a NSTask that runs md5 -s salt+key+salt2 and it  
works, but I am getting a leak with NSTask...
I would like to find out how to get rid of that leak; here is my code  
so you can give me pointers or help me find this out.


- (NSString *)md5:(NSString *)MD5 {
NSPipe *outPipe = [NSPipe pipe];

NSTask* theTask = [[NSTask alloc] init];
[theTask setStandardOutput:[outPipe autorelease]];
[theTask setLaunchPath:@"/sbin/md5"];
[theTask setCurrentDirectoryPath:@"~/"];
	[theTask setArguments:[[NSArray arrayWithObjects:@"-s", MD5, nil]  
autorelease]];

[theTask launch];
[theTask waitUntilExit];
	NSString *rMD5 = NSString alloc] initWithData:[[outPipe  
fileHandleForReading] readDataToEndOfFile] encoding:  
NSUTF8StringEncoding] componentsSeparatedByString:@" = "]  
objectAtIndex:1];

[theTask release];

rMD5 = [self replace:@"\n" with:@"" source:rMD5];

return [rMD5 autorelease];
}

Thanks,
Mr. Gecko
___

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