Changeset ef06c74 in mod_gnutls for src/gnutls_ocsp.c


Ignore:
Timestamp:
Jun 18, 2016, 3:18:36 PM (4 years ago)
Author:
Thomas Klute <thomas2.klute@…>
Branches:
debian/master, debian/stretch-backports, master, upstream
Children:
f1147b6
Parents:
ac3f500
Message:

Compatibility code for GCC version < 5

The builtin_add_overflow() which is used for safe integer type
conversion was introduced with GCC 5, and thus unfortunately is not
available in Debian stable.

The "!defined(clang)" part in the version check is because Clang
3.8 has the builtin, but pretends to be GCC 4 as far as the GNUC
macro is concerned.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gnutls_ocsp.c

    rac3f500 ref06c74  
    393393     * (unsigned int) and fplen (size_t) may have different
    394394     * lengths. */
     395#if defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__)
     396    if (__builtin_expect(fplen <= UINT_MAX, 1))
     397    {
     398        fingerprint.size = (unsigned int) fplen;
     399        fingerprint.data = fp;
     400    }
     401#else
    395402    if (__builtin_add_overflow(fplen, 0, &fingerprint.size))
    396403        fingerprint.size = 0;
    397404    else
    398405        fingerprint.data = fp;
     406#endif
    399407    return fingerprint;
    400408}
     
    541549    }
    542550
    543     /* With the length restriction this really should not happen. */
     551    /* With the length restriction this really should not overflow. */
     552#if defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__)
     553    if (__builtin_expect(len > UINT_MAX, 0))
     554#else
    544555    if (__builtin_add_overflow(len, 0, &response->size))
     556#endif
    545557    {
    546558        response->data = NULL;
     
    549561    else
    550562    {
     563#if defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__)
     564        response->size = (unsigned int) len;
     565#endif
    551566        response->data = apr_pmemdup(p, buf, len);
    552567    }
Note: See TracChangeset for help on using the changeset viewer.