[Heimdal-source-changes] [heimdal/heimdal] c7528f: krb5/crypto: Fix compiler error in new iovec CTS c...

GitHub noreply at github.com
Mon May 28 13:05:04 CEST 2018


  Branch: refs/heads/sxw/iovec-fixes
  Home:   https://github.com/heimdal/heimdal
  Commit: c7528f66d518907764681902f370c7a66c1ecd0d
      https://github.com/heimdal/heimdal/commit/c7528f66d518907764681902f370c7a66c1ecd0d
  Author: Simon Wilkinson <sxw at auristor.com>
  Date:   2018-05-28 (Mon, 28 May 2018)

  Changed paths:
    M lib/krb5/crypto-evp.c

  Log Message:
  -----------
  krb5/crypto: Fix compiler error in new iovec CTS code

Some versions of gcc can't follow the logic in the encryption path
of the _krb5_evp_encrypt_iov_cts code, and believe that it is
possible for the lastpos structure to be used uninitialised.

This isn't actually possible. On entry to the loop, remaining is
guaranteed to be both greater than, and a multiple of blocksize.
In order to exit the loop, remaining must be set to 0. If
cursor.current.length >= remaining, then we set remaining to 0 and
also set lastpos. Otherwise, we calculate the number of whole blocks
in the current iovec, which must be less than remaining, and subtract
that from remaining. Remaining must still be a multiple of and greater
than or equal to blocksize. If remaining == blocksize, we set lastpos,
and set remaining to 0. Otherwise we consume a single block, and go
around again. All of the paths which may set remaining to 0 also
set lastpos, so lastpos must be populated when the loop terminates.

Coverity has a similiar misconception, albeit with ivec2, which is
mistaken for the same reasons.



      **NOTE:** This service been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/

      Functionality will be removed from GitHub.com on January 31st, 2019.


More information about the Heimdal-source-changes mailing list