openssh-7.5p1-x509-libressl.patch 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. diff -urN openssh-7.5p1.orig/a_utf8.c openssh-7.5p1/a_utf8.c
  2. --- openssh-7.5p1.orig/a_utf8.c 1970-01-01 00:00:00.000000000 +0000
  3. +++ openssh-7.5p1/a_utf8.c 2017-03-30 17:38:25.179532110 +0000
  4. @@ -0,0 +1,186 @@
  5. +/*
  6. + * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
  7. + *
  8. + * Licensed under the OpenSSL license (the "License"). You may not use
  9. + * this file except in compliance with the License. You can obtain a copy
  10. + * in the file LICENSE in the source distribution or at
  11. + * https://www.openssl.org/source/license.html
  12. + */
  13. +
  14. +#include <stdio.h>
  15. +
  16. +/* UTF8 utilities */
  17. +
  18. +/*-
  19. + * This parses a UTF8 string one character at a time. It is passed a pointer
  20. + * to the string and the length of the string. It sets 'value' to the value of
  21. + * the current character. It returns the number of characters read or a
  22. + * negative error code:
  23. + * -1 = string too short
  24. + * -2 = illegal character
  25. + * -3 = subsequent characters not of the form 10xxxxxx
  26. + * -4 = character encoded incorrectly (not minimal length).
  27. + */
  28. +
  29. +int UTF8_getc(const unsigned char *str, int len, unsigned long *val)
  30. +{
  31. + const unsigned char *p;
  32. + unsigned long value;
  33. + int ret;
  34. + if (len <= 0)
  35. + return 0;
  36. + p = str;
  37. +
  38. + /* Check syntax and work out the encoded value (if correct) */
  39. + if ((*p & 0x80) == 0) {
  40. + value = *p++ & 0x7f;
  41. + ret = 1;
  42. + } else if ((*p & 0xe0) == 0xc0) {
  43. + if (len < 2)
  44. + return -1;
  45. + if ((p[1] & 0xc0) != 0x80)
  46. + return -3;
  47. + value = (*p++ & 0x1f) << 6;
  48. + value |= *p++ & 0x3f;
  49. + if (value < 0x80)
  50. + return -4;
  51. + ret = 2;
  52. + } else if ((*p & 0xf0) == 0xe0) {
  53. + if (len < 3)
  54. + return -1;
  55. + if (((p[1] & 0xc0) != 0x80)
  56. + || ((p[2] & 0xc0) != 0x80))
  57. + return -3;
  58. + value = (*p++ & 0xf) << 12;
  59. + value |= (*p++ & 0x3f) << 6;
  60. + value |= *p++ & 0x3f;
  61. + if (value < 0x800)
  62. + return -4;
  63. + ret = 3;
  64. + } else if ((*p & 0xf8) == 0xf0) {
  65. + if (len < 4)
  66. + return -1;
  67. + if (((p[1] & 0xc0) != 0x80)
  68. + || ((p[2] & 0xc0) != 0x80)
  69. + || ((p[3] & 0xc0) != 0x80))
  70. + return -3;
  71. + value = ((unsigned long)(*p++ & 0x7)) << 18;
  72. + value |= (*p++ & 0x3f) << 12;
  73. + value |= (*p++ & 0x3f) << 6;
  74. + value |= *p++ & 0x3f;
  75. + if (value < 0x10000)
  76. + return -4;
  77. + ret = 4;
  78. + } else if ((*p & 0xfc) == 0xf8) {
  79. + if (len < 5)
  80. + return -1;
  81. + if (((p[1] & 0xc0) != 0x80)
  82. + || ((p[2] & 0xc0) != 0x80)
  83. + || ((p[3] & 0xc0) != 0x80)
  84. + || ((p[4] & 0xc0) != 0x80))
  85. + return -3;
  86. + value = ((unsigned long)(*p++ & 0x3)) << 24;
  87. + value |= ((unsigned long)(*p++ & 0x3f)) << 18;
  88. + value |= ((unsigned long)(*p++ & 0x3f)) << 12;
  89. + value |= (*p++ & 0x3f) << 6;
  90. + value |= *p++ & 0x3f;
  91. + if (value < 0x200000)
  92. + return -4;
  93. + ret = 5;
  94. + } else if ((*p & 0xfe) == 0xfc) {
  95. + if (len < 6)
  96. + return -1;
  97. + if (((p[1] & 0xc0) != 0x80)
  98. + || ((p[2] & 0xc0) != 0x80)
  99. + || ((p[3] & 0xc0) != 0x80)
  100. + || ((p[4] & 0xc0) != 0x80)
  101. + || ((p[5] & 0xc0) != 0x80))
  102. + return -3;
  103. + value = ((unsigned long)(*p++ & 0x1)) << 30;
  104. + value |= ((unsigned long)(*p++ & 0x3f)) << 24;
  105. + value |= ((unsigned long)(*p++ & 0x3f)) << 18;
  106. + value |= ((unsigned long)(*p++ & 0x3f)) << 12;
  107. + value |= (*p++ & 0x3f) << 6;
  108. + value |= *p++ & 0x3f;
  109. + if (value < 0x4000000)
  110. + return -4;
  111. + ret = 6;
  112. + } else
  113. + return -2;
  114. + *val = value;
  115. + return ret;
  116. +}
  117. +
  118. +/*
  119. + * This takes a character 'value' and writes the UTF8 encoded value in 'str'
  120. + * where 'str' is a buffer containing 'len' characters. Returns the number of
  121. + * characters written or -1 if 'len' is too small. 'str' can be set to NULL
  122. + * in which case it just returns the number of characters. It will need at
  123. + * most 6 characters.
  124. + */
  125. +
  126. +int UTF8_putc(unsigned char *str, int len, unsigned long value)
  127. +{
  128. + if (!str)
  129. + len = 6; /* Maximum we will need */
  130. + else if (len <= 0)
  131. + return -1;
  132. + if (value < 0x80) {
  133. + if (str)
  134. + *str = (unsigned char)value;
  135. + return 1;
  136. + }
  137. + if (value < 0x800) {
  138. + if (len < 2)
  139. + return -1;
  140. + if (str) {
  141. + *str++ = (unsigned char)(((value >> 6) & 0x1f) | 0xc0);
  142. + *str = (unsigned char)((value & 0x3f) | 0x80);
  143. + }
  144. + return 2;
  145. + }
  146. + if (value < 0x10000) {
  147. + if (len < 3)
  148. + return -1;
  149. + if (str) {
  150. + *str++ = (unsigned char)(((value >> 12) & 0xf) | 0xe0);
  151. + *str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
  152. + *str = (unsigned char)((value & 0x3f) | 0x80);
  153. + }
  154. + return 3;
  155. + }
  156. + if (value < 0x200000) {
  157. + if (len < 4)
  158. + return -1;
  159. + if (str) {
  160. + *str++ = (unsigned char)(((value >> 18) & 0x7) | 0xf0);
  161. + *str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
  162. + *str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
  163. + *str = (unsigned char)((value & 0x3f) | 0x80);
  164. + }
  165. + return 4;
  166. + }
  167. + if (value < 0x4000000) {
  168. + if (len < 5)
  169. + return -1;
  170. + if (str) {
  171. + *str++ = (unsigned char)(((value >> 24) & 0x3) | 0xf8);
  172. + *str++ = (unsigned char)(((value >> 18) & 0x3f) | 0x80);
  173. + *str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
  174. + *str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
  175. + *str = (unsigned char)((value & 0x3f) | 0x80);
  176. + }
  177. + return 5;
  178. + }
  179. + if (len < 6)
  180. + return -1;
  181. + if (str) {
  182. + *str++ = (unsigned char)(((value >> 30) & 0x1) | 0xfc);
  183. + *str++ = (unsigned char)(((value >> 24) & 0x3f) | 0x80);
  184. + *str++ = (unsigned char)(((value >> 18) & 0x3f) | 0x80);
  185. + *str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
  186. + *str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
  187. + *str = (unsigned char)((value & 0x3f) | 0x80);
  188. + }
  189. + return 6;
  190. +}
  191. diff -urN openssh-7.5p1.orig/Makefile.in openssh-7.5p1/Makefile.in
  192. --- openssh-7.5p1.orig/Makefile.in 2017-03-30 17:33:30.983830629 +0000
  193. +++ openssh-7.5p1/Makefile.in 2017-03-30 17:39:28.392905858 +0000
  194. @@ -74,7 +74,7 @@
  195. @OCSP_ON@OCSP_OBJS=ssh-ocsp.o
  196. @OCSP_OFF@OCSP_OBJS=
  197. -SSHX509_OBJS=ssh-x509.o ssh-xkalg.o x509_nm_cmp.o key-eng.o
  198. +SSHX509_OBJS=ssh-x509.o ssh-xkalg.o x509_nm_cmp.o key-eng.o a_utf8.o
  199. X509STORE_OBJS=x509store.o $(LDAP_OBJS)
  200. TARGETS=ssh$(EXEEXT) sshd$(EXEEXT) ssh-add$(EXEEXT) ssh-keygen$(EXEEXT) ssh-keyscan${EXEEXT} ssh-keysign${EXEEXT} ssh-pkcs11-helper$(EXEEXT) ssh-agent$(EXEEXT) scp$(EXEEXT) sftp-server$(EXEEXT) sftp$(EXEEXT)