diff options
author | des <des@FreeBSD.org> | 2003-01-22 10:55:36 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2003-01-22 10:55:36 +0000 |
commit | 58c84d11b03cad8da26cbc3fed01e735ec7f1647 (patch) | |
tree | 9b5294612d80bd0160cf8e56dee0f652d1cf7445 /contrib | |
parent | c1ad619ef7136cbc5a0e4902bed088f62ad25604 (diff) | |
download | FreeBSD-src-58c84d11b03cad8da26cbc3fed01e735ec7f1647.zip FreeBSD-src-58c84d11b03cad8da26cbc3fed01e735ec7f1647.tar.gz |
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
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/opie/libopie/newseed.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/contrib/opie/libopie/newseed.c b/contrib/opie/libopie/newseed.c index f32b075..2965b0e 100644 --- a/contrib/opie/libopie/newseed.c +++ b/contrib/opie/libopie/newseed.c @@ -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; } } |