Advertisement
Guest User

boringssl patch for grpc/grpc

a guest
Sep 20th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 8.09 KB | None | 0 0
  1. diff --git a/crypto/bio/fd.c b/crypto/bio/fd.c
  2. index 4e9eeacf..a40d36fc 100644
  3. --- a/crypto/bio/fd.c
  4. +++ b/crypto/bio/fd.c
  5. @@ -190,6 +190,7 @@ static long fd_ctrl(BIO *b, int cmd, long num, void *ptr) {
  6.    switch (cmd) {
  7.      case BIO_CTRL_RESET:
  8.        num = 0;
  9. +      FALLTHRU;
  10.      case BIO_C_FILE_SEEK:
  11.        ret = 0;
  12.        if (b->init) {
  13. diff --git a/crypto/bio/file.c b/crypto/bio/file.c
  14. index 3580cd1c..9cdde5cf 100644
  15. --- a/crypto/bio/file.c
  16. +++ b/crypto/bio/file.c
  17. @@ -184,6 +184,7 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr) {
  18.    switch (cmd) {
  19.      case BIO_CTRL_RESET:
  20.        num = 0;
  21. +      FALLTHRU;
  22.      case BIO_C_FILE_SEEK:
  23.        ret = (long)fseek(fp, num, 0);
  24.        break;
  25. diff --git a/crypto/bn/mul.c b/crypto/bn/mul.c
  26. index fdf2c692..8db21753 100644
  27. --- a/crypto/bn/mul.c
  28. +++ b/crypto/bn/mul.c
  29. @@ -230,11 +230,13 @@ static BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a,
  30.              if (--dl <= 0) {
  31.                break;
  32.              }
  33. +            FALLTHRU;
  34.            case 2:
  35.              r[2] = a[2];
  36.              if (--dl <= 0) {
  37.                break;
  38.              }
  39. +            FALLTHRU;
  40.            case 3:
  41.              r[3] = a[3];
  42.              if (--dl <= 0) {
  43. diff --git a/crypto/cipher/e_rc2.c b/crypto/cipher/e_rc2.c
  44. index e1b4301e..ca8e9604 100644
  45. --- a/crypto/cipher/e_rc2.c
  46. +++ b/crypto/cipher/e_rc2.c
  47. @@ -75,18 +75,25 @@
  48.      switch (n) {                               \
  49.        case 8:                                  \
  50.          (l2) = ((uint32_t)(*(--(c)))) << 24L;  \
  51. +        FALLTHRU;                              \
  52.        case 7:                                  \
  53.          (l2) |= ((uint32_t)(*(--(c)))) << 16L; \
  54. +        FALLTHRU;                              \
  55.        case 6:                                  \
  56.          (l2) |= ((uint32_t)(*(--(c)))) << 8L;  \
  57. +        FALLTHRU;                              \
  58.        case 5:                                  \
  59.          (l2) |= ((uint32_t)(*(--(c))));        \
  60. +        FALLTHRU;                              \
  61.        case 4:                                  \
  62.          (l1) = ((uint32_t)(*(--(c)))) << 24L;  \
  63. +        FALLTHRU;                              \
  64.        case 3:                                  \
  65.          (l1) |= ((uint32_t)(*(--(c)))) << 16L; \
  66. +        FALLTHRU;                              \
  67.        case 2:                                  \
  68.          (l1) |= ((uint32_t)(*(--(c)))) << 8L;  \
  69. +        FALLTHRU;                              \
  70.        case 1:                                  \
  71.          (l1) |= ((uint32_t)(*(--(c))));        \
  72.      }                                          \
  73. @@ -106,18 +113,25 @@
  74.      switch (n) {                                    \
  75.        case 8:                                       \
  76.          *(--(c)) = (uint8_t)(((l2) >> 24L) & 0xff); \
  77. +        FALLTHRU;                                   \
  78.        case 7:                                       \
  79.          *(--(c)) = (uint8_t)(((l2) >> 16L) & 0xff); \
  80. +        FALLTHRU;                                   \
  81.        case 6:                                       \
  82.          *(--(c)) = (uint8_t)(((l2) >> 8L) & 0xff);  \
  83. +        FALLTHRU;                                   \
  84.        case 5:                                       \
  85.          *(--(c)) = (uint8_t)(((l2)) & 0xff);        \
  86. +        FALLTHRU;                                   \
  87.        case 4:                                       \
  88.          *(--(c)) = (uint8_t)(((l1) >> 24L) & 0xff); \
  89. +        FALLTHRU;                                   \
  90.        case 3:                                       \
  91.          *(--(c)) = (uint8_t)(((l1) >> 16L) & 0xff); \
  92. +        FALLTHRU;                                   \
  93.        case 2:                                       \
  94.          *(--(c)) = (uint8_t)(((l1) >> 8L) & 0xff);  \
  95. +        FALLTHRU;                                   \
  96.        case 1:                                       \
  97.          *(--(c)) = (uint8_t)(((l1)) & 0xff);        \
  98.      }                                               \
  99. diff --git a/crypto/des/internal.h b/crypto/des/internal.h
  100. index 21eb9335..70e7e24a 100644
  101. --- a/crypto/des/internal.h
  102. +++ b/crypto/des/internal.h
  103. @@ -88,18 +88,25 @@ extern "C" {
  104.      switch (n) {                               \
  105.        case 8:                                  \
  106.          (l2) = ((uint32_t)(*(--(c)))) << 24L;  \
  107. +        FALLTHRU;                              \
  108.        case 7:                                  \
  109.          (l2) |= ((uint32_t)(*(--(c)))) << 16L; \
  110. +        FALLTHRU;                              \
  111.        case 6:                                  \
  112.          (l2) |= ((uint32_t)(*(--(c)))) << 8L;  \
  113. +        FALLTHRU;                              \
  114.        case 5:                                  \
  115.          (l2) |= ((uint32_t)(*(--(c))));        \
  116. +        FALLTHRU;                              \
  117.        case 4:                                  \
  118.          (l1) = ((uint32_t)(*(--(c)))) << 24L;  \
  119. +        FALLTHRU;                              \
  120.        case 3:                                  \
  121.          (l1) |= ((uint32_t)(*(--(c)))) << 16L; \
  122. +        FALLTHRU;                              \
  123.        case 2:                                  \
  124.          (l1) |= ((uint32_t)(*(--(c)))) << 8L;  \
  125. +        FALLTHRU;                              \
  126.        case 1:                                  \
  127.          (l1) |= ((uint32_t)(*(--(c))));        \
  128.      }                                          \
  129. @@ -112,18 +119,25 @@ extern "C" {
  130.      switch (n) {                                          \
  131.        case 8:                                             \
  132.          *(--(c)) = (unsigned char)(((l2) >> 24L) & 0xff); \
  133. +        FALLTHRU;                                   \
  134.        case 7:                                             \
  135.          *(--(c)) = (unsigned char)(((l2) >> 16L) & 0xff); \
  136. +        FALLTHRU;                                   \
  137.        case 6:                                             \
  138.          *(--(c)) = (unsigned char)(((l2) >> 8L) & 0xff);  \
  139. +        FALLTHRU;                                   \
  140.        case 5:                                             \
  141.          *(--(c)) = (unsigned char)(((l2)) & 0xff);        \
  142. +        FALLTHRU;                                   \
  143.        case 4:                                             \
  144.          *(--(c)) = (unsigned char)(((l1) >> 24L) & 0xff); \
  145. +        FALLTHRU;                                   \
  146.        case 3:                                             \
  147.          *(--(c)) = (unsigned char)(((l1) >> 16L) & 0xff); \
  148. +        FALLTHRU;                                   \
  149.        case 2:                                             \
  150.          *(--(c)) = (unsigned char)(((l1) >> 8L) & 0xff);  \
  151. +        FALLTHRU;                                   \
  152.        case 1:                                             \
  153.          *(--(c)) = (unsigned char)(((l1)) & 0xff);        \
  154.      }                                                     \
  155. diff --git a/include/openssl/base.h b/include/openssl/base.h
  156. index 3f47521d..33ab4f97 100644
  157. --- a/include/openssl/base.h
  158. +++ b/include/openssl/base.h
  159. @@ -75,6 +75,17 @@
  160.  extern "C" {
  161.  #endif
  162.  
  163. +// Have a generic fall-through for different versions of C++
  164. +#if defined(__cplusplus) && __cplusplus >= 201402L // C++14, C++17 and above
  165. +#define FALLTHRU [[fallthrough]]
  166. +#elif defined(__cplusplus) && __cplusplus >= 201103L && __GNUC__ >= 7 // C++11 gcc 7
  167. +#define FALLTHRU [[gnu::fallthrough]]
  168. +#elif  __GNUC__ >= 7 // gcc 7
  169. +#define FALLTHRU __attribute__ ((fallthrough))
  170. +#else // C++11 on gcc 6, and all other cases
  171. +#define FALLTHRU
  172. +#endif
  173. +
  174.  
  175.  #if defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64)
  176.  #define OPENSSL_64_BIT
  177. diff --git a/ssl/tls13_both.c b/ssl/tls13_both.c
  178. index 91cae9ad..b2ffe056 100644
  179. --- a/ssl/tls13_both.c
  180. +++ b/ssl/tls13_both.c
  181. @@ -54,7 +54,7 @@ int tls13_handshake(SSL_HANDSHAKE *hs) {
  182.          }
  183.          ssl->method->expect_flight(ssl);
  184.          hs->wait = ssl_hs_read_message;
  185. -        /* Fall-through. */
  186. +        FALLTHRU;
  187.        }
  188.  
  189.        case ssl_hs_read_message: {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement