Fix loop condition in ber.c. Discussed with claudio.
authorrob <rob@openbsd.org>
Fri, 13 Jul 2018 08:30:10 +0000 (08:30 +0000)
committerrob <rob@openbsd.org>
Fri, 13 Jul 2018 08:30:10 +0000 (08:30 +0000)
ok claudio@, jca@

usr.bin/ldap/ber.c
usr.sbin/ldapd/ber.c
usr.sbin/snmpd/ber.c
usr.sbin/ypldap/ber.c

index ffdafb2..47f0880 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ber.c,v 1.12 2018/07/09 09:21:26 jca Exp $ */
+/*     $OpenBSD: ber.c,v 1.13 2018/07/13 08:30:10 rob Exp $ */
 
 /*
  * Copyright (c) 2007, 2012 Reyk Floeter <reyk@openbsd.org>
@@ -1032,13 +1032,12 @@ get_id(struct ber *b, unsigned long *tag, int *class, int *cstruct)
                        return -1;
                t = (t << 7) | (u & ~BER_TAG_MORE);
                i++;
+               if (i > sizeof(unsigned long)) {
+                       errno = ERANGE;
+                       return -1;
+               }
        } while (u & BER_TAG_MORE);
 
-       if (i > sizeof(unsigned long)) {
-               errno = ERANGE;
-               return -1;
-       }
-
        *tag = t;
        return i + 1;
 }
index 65c952b..0b955b3 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ber.c,v 1.22 2018/07/09 09:21:26 jca Exp $ */
+/*     $OpenBSD: ber.c,v 1.23 2018/07/13 08:30:10 rob Exp $ */
 
 /*
  * Copyright (c) 2007, 2012 Reyk Floeter <reyk@openbsd.org>
@@ -1032,13 +1032,12 @@ get_id(struct ber *b, unsigned long *tag, int *class, int *cstruct)
                        return -1;
                t = (t << 7) | (u & ~BER_TAG_MORE);
                i++;
+               if (i > sizeof(unsigned long)) {
+                       errno = ERANGE;
+                       return -1;
+               }
        } while (u & BER_TAG_MORE);
 
-       if (i > sizeof(unsigned long)) {
-               errno = ERANGE;
-               return -1;
-       }
-
        *tag = t;
        return i + 1;
 }
index a760edd..7a966e6 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ber.c,v 1.41 2018/07/09 09:21:26 jca Exp $ */
+/*     $OpenBSD: ber.c,v 1.42 2018/07/13 08:30:10 rob Exp $ */
 
 /*
  * Copyright (c) 2007, 2012 Reyk Floeter <reyk@openbsd.org>
@@ -1032,13 +1032,12 @@ get_id(struct ber *b, unsigned long *tag, int *class, int *cstruct)
                        return -1;
                t = (t << 7) | (u & ~BER_TAG_MORE);
                i++;
+               if (i > sizeof(unsigned long)) {
+                       errno = ERANGE;
+                       return -1;
+               }
        } while (u & BER_TAG_MORE);
 
-       if (i > sizeof(unsigned long)) {
-               errno = ERANGE;
-               return -1;
-       }
-
        *tag = t;
        return i + 1;
 }
index c2696f2..fc714e0 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ber.c,v 1.24 2018/07/09 09:21:26 jca Exp $ */
+/*     $OpenBSD: ber.c,v 1.25 2018/07/13 08:30:10 rob Exp $ */
 
 /*
  * Copyright (c) 2007, 2012 Reyk Floeter <reyk@openbsd.org>
@@ -1032,13 +1032,12 @@ get_id(struct ber *b, unsigned long *tag, int *class, int *cstruct)
                        return -1;
                t = (t << 7) | (u & ~BER_TAG_MORE);
                i++;
+               if (i > sizeof(unsigned long)) {
+                       errno = ERANGE;
+                       return -1;
+               }
        } while (u & BER_TAG_MORE);
 
-       if (i > sizeof(unsigned long)) {
-               errno = ERANGE;
-               return -1;
-       }
-
        *tag = t;
        return i + 1;
 }