When computing a new seed for an existing user, opienewseed() would

incorrectly compute the length of the numeric portion of the previous
seed, causing the new seed to be one character shorter than the old
one.

This patch has been submitted to the vendor; I'm committing it right
away since the file is already off the vendor branch.

MFC after:	3 days
This commit is contained in:
des 2003-01-22 10:55:36 +00:00
parent c1ad619ef7
commit 58c84d11b0

View File

@ -43,22 +43,21 @@ int opienewseed FUNCTION((seed), char *seed)
return -1;
if (seed[0]) {
char *c, *end;
char *c;
unsigned int i, max;
if ((i = strlen(seed)) > OPIE_SEED_MAX)
i = OPIE_SEED_MAX;
for (c = end = seed + i - 1, max = 1;
(c > seed) && isdigit(*c); c--)
for (c = seed + i - 1, max = 1;
(c >= seed) && isdigit(*c); c--)
max *= 10;
if ((i = strtoul(++c, (char **)0, 10)) < max) {
if (++i >= max)
i = 1;
snprintf(c, end - c, "%d", i);
seed[OPIE_SEED_MAX] = 0;
sprintf(c, "%d", i);
return 0;
}
}