Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XCode 2.1 - different result from crypt in deployment and debug?



On 08.06.2005 17:29, "Rick Jansen" <email@hidden> wrote:

> Below's the code. I must have done something wrong...

  Yes, you are working with random locations in memory. When the compiler
gave an error about incorrect pointer types, you shouldn't have shut it up
with a cast. Also, don't forget about the trailing zero in C strings.

>   char pw[8];
>   [Password getCString:(char *)&pw maxLength:8];

  Should be:

   char pw[9];
   [Password getCString:pw maxLength:8];

  Also, getCString:maxLength: is deprecated in 10.4 (they don't say what to
use instead; I recommend CFStringGetCString() ;) )

>   char seed[2];
>   [Seed getCString:(char *)&seed maxLength:2];

  Replicated several more times...

>   // Crypt
>   char encrypted[256];  // Assume 256 is enough
>   char *encryptedPtr;
>   encryptedPtr = (char *)&encrypted;
>   encryptedPtr = crypt( (char *)&pw, (char *)&seed );
> 
>   // Convert crypted C-string to NSString
>   NSString *Encoded = [[NSString alloc] initWithCString:encryptedPtr];
>   NSLog(@"CheckRegisterCode: encoded %@ is: %@", Password, Encoded);
> 
>   // more code...
>   return NO;
> }

- WBR, Alexey Proskuryakov


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to email@hidden

References: 
 >Re: XCode 2.1 - different result from crypt in deployment and debug? (From: Rick Jansen <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.