From 58c84d11b03cad8da26cbc3fed01e735ec7f1647 Mon Sep 17 00:00:00 2001 From: des Date: Wed, 22 Jan 2003 10:55:36 +0000 Subject: 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 --- contrib/opie/libopie/newseed.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'contrib/opie') 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; } } -- cgit v1.1