I don't know about the one error, but strncmp does use 3 args. Your thinkin
of strcmp.  strncmp uses a 3rd argument so that when it's comparing, it
won't go over the 3rd arg so that there is no buffer overflowing. strncpy
does the same thing. You use the 3rd arg so that when it's copying, to "make
sure" that it does not go over the length of the string it's copying.

Try getting rid of the macro and use the function itself since macro is just
duplicate anyways. I think the macro is returning a true/false(1/0) instead
of the decrypted password.
Just a thought.

Rheede



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Francois
Rossouw
Sent: Friday, May 24, 2002 7:24 AM
To: Edwin Groothuis
Cc: [email protected]
Subject: Re: Stupid Question


Whoops, knew I forgot something :)

#define CRYPT(x,y)                              crypt(x,y)

Why this is done, I don't really know.
From the way I understand it, you could simply have said:
if (!ch || (strncmp (crypt(argument, GET_PASSWD(ch)), GET_PASSWD (ch),
MAX_PWD_LENGTH)))
But, would it not be better to simply use strcmp? it only needs 2 arguments,
not 3, and from what I see, there's no real difference...

I dunno..
Sometimes it really frustrates me to try and understand why some people did
things in a certain why.

Frans


Reply via email to