X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fsrc%2Fcrypt16.c;h=56353c326af2a8405410cffa7f5f4c3d58736c3e;hb=2f6c7b1aa0bf4a675d0ec95646b27f5c71bf06c2;hp=4341356692008f17a9b5813a11f58720e9f6721d;hpb=059ec3d9952740285fb1ebf47961b8aca2eb1b4a;p=exim.git diff --git a/src/src/crypt16.c b/src/src/crypt16.c index 434135669..56353c326 100644 --- a/src/src/crypt16.c +++ b/src/src/crypt16.c @@ -1,5 +1,3 @@ -/* $Cambridge: exim/src/src/crypt16.c,v 1.1 2004/10/07 10:39:01 ph10 Exp $ */ - /* * Copyright (c) 2000-2002 * Chris Adams @@ -46,31 +44,33 @@ static void dummy(int x) { dummy(x-1); } #include #endif -char *crypt16(char *key, char *salt) +char * +crypt16(char *key, char *salt) { - static char res[25]; - static char s2[3]; - char *p; +static char res[25]; /* Not threadsafe; like crypt() */ +static char s2[3]; +char *p; + +/* Clear the string of any previous data */ +memset (res, 0, sizeof (res)); - /* Clear the string of any previous data */ - memset (res, 0, sizeof (res)); +/* crypt the first part */ +if (!(p = crypt (key, salt))) return NULL; +strncpy (res, p, 13); - /* crypt the first part */ - p = crypt (key, salt); - strncpy (res, p, 13); +if (strlen (key) > 8) + { + /* crypt the rest + * the first two characters of the first block (not counting + * the salt) make up the new salt */ - if (strlen (key) > 8) - { - /* crypt the rest - * the first two characters of the first block (not counting - * the salt) make up the new salt */ - strncpy (s2, &(res[2]), 2); - p = crypt (&(key[8]), s2); - strncpy (&(res[13]), &(p[2]), 11); - memset (s2, 0, sizeof (s2)); - } + strncpy (s2, res+2, 2); + p = crypt (key+8, s2); + strncpy (res+13, p+2, 11); + memset (s2, 0, sizeof(s2)); + } - return (res); +return (res); } #endif