FreeBSD/contrib/subversion/subversion/libsvn_subr/packed_data.c
/* Read one 7b/8b encoded value from *P and return it in *RESULT.  Returns
 * the first position after the parsed data.
 *
 * Overflows will be detected in the sense that it will end parsing the
 * input but the result is undefined.
 */
Read one 7b/8b encoded value from *P and return it in *RESULT.  Returns
the first position after the parsed data.

Overflows will be detected in the sense that it will end parsing the
input but the result is undefined.
Read one 7b / 8b encoded value from * P and return it in * RESULT . Returns the first position after the parsed data . Overflows will be detected in the sense that it will end parsing the input but the result is undefined .
static unsigned char *
read_packed_uint_body(unsigned char *p, apr_uint64_t *result)
{
  if (*p < 0x80)
    {
      *result = *p;
    }
  else
    {
      apr_uint64_t shift = 0;
      apr_uint64_t value = 0;
      while (*p >= 0x80)
        {
          value += (apr_uint64_t)(*p & 0x7f) << shift;
          ++p;
          shift += 7;
          if (shift > 64)
            {
              *result = 0;
              return p;
            }
        }
      *result = value + ((apr_uint64_t)*p << shift);
    }
  return ++p;
}
static unsigned char * read_packed_uint_body ( unsigned char * p , apr_uint64_t * result ) { if ( * p < 0x80 ) { * result = * p ; } else { apr_uint64_t shift = 0 ; apr_uint64_t value = 0 ; while ( * p >= 0x80 ) { value += ( apr_uint64_t ) ( * p & 0x7f ) << shift ; ++ p ; shift += 7 ; if ( shift > 64 ) { * result = 0 ; return p ; } } * result = value + ( ( apr_uint64_t ) * p << shift ) ; } return ++ p ; }
Read one 7b/8b encoded value from *P and return it in *RESULT.
Read one 7b / 8b encoded value from * P and return it in * RESULT .
/* a definite overflow.  Note, that numbers of 65 .. 70
                 bits will not be detected as an overflow as they don't
                 threaten to exceed the input buffer. */