/** Parses a password. * This routine can parse a pass that has a salt (new as of unreal 3.2.1) * and will set the 'salt' pointer and 'hash' accordingly. * RETURN VALUES: * 1 If succeeded, salt and hash can be used. * 0 If it's a password without a salt ('old'), salt and hash are not touched. */ static int parsepass(char *str, char **salt, char **hash) { static char saltbuf[MAXSALTLEN+1], hashbuf[MAXHASHLEN+1]; char *p; int max; /* Syntax: $$ */ if (*str != '$') return 0; p = strchr(str+1, '$'); if (!p || (p == str+1) || !p[1]) return 0; max = p - str; if (max > sizeof(saltbuf)) max = sizeof(saltbuf); strlcpy(saltbuf, str+1, max); strlcpy(hashbuf, p+1, sizeof(hashbuf)); *salt = saltbuf; *hash = hashbuf; return 1; }