Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Aug 2014 12:26:49 +0000 (UTC)
From:      Andrey A. Chernov <ache@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r269806 - in head/contrib/opie: . libopie
Message-ID:  <53e8b689.2f28.3febd085@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ache
Date: Mon Aug 11 12:26:48 2014
New Revision: 269806
URL: http://svnweb.freebsd.org/changeset/base/269806

Log:
  Fix too long (seed length >12 chars) challenge handling.
  1) " ext" length should be included into OPIE_CHALLENGE_MAX (as all places
  of opie code expects that).
  2) Overflow check in challenge.c is off by 1 even with corrected
  OPIE_CHALLENGE_MAX
  3) When fallback to randomchallenge() happens and rval is 0 (i.e.
  challenge is too long), its value should be set to error state too.
  
  To demonstrate the bug, run opiepasswd with valid seed:
  opiepasswd -s 1234567890123456
  and notice that it falls back to randomchallenge() (i.e. no
  1234567890123456 in the prompt).
  
  PR:             191511
  Submitted by:   mitsururike@gmail.com (partially)
  MFC after:      1 week

Modified:
  head/contrib/opie/libopie/challenge.c
  head/contrib/opie/opie.h

Modified: head/contrib/opie/libopie/challenge.c
==============================================================================
--- head/contrib/opie/libopie/challenge.c	Mon Aug 11 08:58:35 2014	(r269805)
+++ head/contrib/opie/libopie/challenge.c	Mon Aug 11 12:26:48 2014	(r269806)
@@ -68,7 +68,9 @@ int opiechallenge FUNCTION((mp, name, ss
   }
 
   if (rval ||
-    (snprintf(ss, OPIE_CHALLENGE_MAX, "otp-%s %d %s ext", algids[MDX], mp->opie_n - 1, mp->opie_seed) >= OPIE_CHALLENGE_MAX)) {
+    (snprintf(ss, OPIE_CHALLENGE_MAX+1, "otp-%s %d %s ext", algids[MDX], mp->opie_n - 1, mp->opie_seed) >= OPIE_CHALLENGE_MAX+1)) {
+    if (!rval)
+      rval = 1;
     opierandomchallenge(ss);
     memset(mp, 0, sizeof(*mp));
   }

Modified: head/contrib/opie/opie.h
==============================================================================
--- head/contrib/opie/opie.h	Mon Aug 11 08:58:35 2014	(r269805)
+++ head/contrib/opie/opie.h	Mon Aug 11 12:26:48 2014	(r269806)
@@ -72,8 +72,8 @@ struct opie {
 /* Max length of hash algorithm name (md4/md5) */
 #define OPIE_HASHNAME_MAX 3
 
-/* Maximum length of a challenge (otp-md? 9999 seed) */
-#define OPIE_CHALLENGE_MAX (4+OPIE_HASHNAME_MAX+1+4+1+OPIE_SEED_MAX)
+/* Maximum length of a challenge (otp-md? 9999 seed ext) */
+#define OPIE_CHALLENGE_MAX (4+OPIE_HASHNAME_MAX+1+4+1+OPIE_SEED_MAX+1+3)
 
 /* Maximum length of a response that we allow */
 #define OPIE_RESPONSE_MAX (9+1+19+1+9+OPIE_SEED_MAX+1+19+1+19+1+19)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53e8b689.2f28.3febd085>