upstream commit

Even when only writing an unescaped character, the dst
 buffer may need to grow, or it would be overrun; issue found by tb@ with
 malloc.conf(5) 'C'.

While here, reserve an additional byte for the terminating NUL
up front such that we don't have to realloc() later just for that.

OK tb@

Upstream-ID: 30ebcc0c097c4571b16f0a78b44969f170db0cff
1 file changed
tree: a4428fb623a0698643942b14222740abd5e8f423
  1. contrib/
  2. openbsd-compat/
  3. regress/
  4. scard/
  5. .cvsignore
  6. aclocal.m4
  7. addrmatch.c
  8. atomicio.c
  9. atomicio.h
  10. audit-bsm.c
  11. audit-linux.c
  12. audit.c
  13. audit.h
  14. auth-bsdauth.c
  15. auth-chall.c
  16. auth-krb5.c
  17. auth-options.c
  18. auth-options.h
  19. auth-pam.c
  20. auth-pam.h
  21. auth-passwd.c
  22. auth-rh-rsa.c
  23. auth-rhosts.c
  24. auth-rsa.c
  25. auth-shadow.c
  26. auth-sia.c
  27. auth-sia.h
  28. auth-skey.c
  29. auth.c
  30. auth.h
  31. auth1.c
  32. auth2-chall.c
  33. auth2-gss.c
  34. auth2-hostbased.c
  35. auth2-kbdint.c
  36. auth2-none.c
  37. auth2-passwd.c
  38. auth2-pubkey.c
  39. auth2.c
  40. authfd.c
  41. authfd.h
  42. authfile.c
  43. authfile.h
  44. bitmap.c
  45. bitmap.h
  46. blocks.c
  47. bufaux.c
  48. bufbn.c
  49. bufec.c
  50. buffer.c
  51. buffer.h
  52. buildpkg.sh.in
  53. canohost.c
  54. canohost.h
  55. chacha.c
  56. chacha.h
  57. channels.c
  58. channels.h
  59. cipher-3des1.c
  60. cipher-aes.c
  61. cipher-aesctr.c
  62. cipher-aesctr.h
  63. cipher-bf1.c
  64. cipher-chachapoly.c
  65. cipher-chachapoly.h
  66. cipher-ctr.c
  67. cipher.c
  68. cipher.h
  69. cleanup.c
  70. clientloop.c
  71. clientloop.h
  72. compat.c
  73. compat.h
  74. config.guess
  75. config.sub
  76. configure.ac
  77. crc32.c
  78. crc32.h
  79. CREDITS
  80. crypto_api.h
  81. deattack.c
  82. deattack.h
  83. defines.h
  84. dh.c
  85. dh.h
  86. digest-libc.c
  87. digest-openssl.c
  88. digest.h
  89. dispatch.c
  90. dispatch.h
  91. dns.c
  92. dns.h
  93. ed25519.c
  94. entropy.c
  95. entropy.h
  96. fatal.c
  97. fe25519.c
  98. fe25519.h
  99. fixalgorithms
  100. fixpaths
  101. fixprogs
  102. ge25519.c
  103. ge25519.h
  104. ge25519_base.data
  105. groupaccess.c
  106. groupaccess.h
  107. gss-genr.c
  108. gss-serv-krb5.c
  109. gss-serv.c
  110. hash.c
  111. hmac.c
  112. hmac.h
  113. hostfile.c
  114. hostfile.h
  115. includes.h
  116. INSTALL
  117. install-sh
  118. kex.c
  119. kex.h
  120. kexc25519.c
  121. kexc25519c.c
  122. kexc25519s.c
  123. kexdh.c
  124. kexdhc.c
  125. kexdhs.c
  126. kexecdh.c
  127. kexecdhc.c
  128. kexecdhs.c
  129. kexgex.c
  130. kexgexc.c
  131. kexgexs.c
  132. key.c
  133. key.h
  134. krl.c
  135. krl.h
  136. LICENCE
  137. log.c
  138. log.h
  139. loginrec.c
  140. loginrec.h
  141. logintest.c
  142. mac.c
  143. mac.h
  144. Makefile.in
  145. match.c
  146. match.h
  147. md-sha256.c
  148. md5crypt.c
  149. md5crypt.h
  150. mdoc2man.awk
  151. misc.c
  152. misc.h
  153. mkinstalldirs
  154. moduli
  155. moduli.5
  156. moduli.c
  157. monitor.c
  158. monitor.h
  159. monitor_fdpass.c
  160. monitor_fdpass.h
  161. monitor_mm.c
  162. monitor_mm.h
  163. monitor_wrap.c
  164. monitor_wrap.h
  165. msg.c
  166. msg.h
  167. mux.c
  168. myproposal.h
  169. nchan.c
  170. nchan.ms
  171. nchan2.ms
  172. opacket.c
  173. opacket.h
  174. openssh.xml.in
  175. opensshd.init.in
  176. OVERVIEW
  177. packet.c
  178. packet.h
  179. pathnames.h
  180. pkcs11.h
  181. platform-pledge.c
  182. platform.c
  183. platform.h
  184. poly1305.c
  185. poly1305.h
  186. progressmeter.c
  187. progressmeter.h
  188. PROTOCOL
  189. PROTOCOL.agent
  190. PROTOCOL.certkeys
  191. PROTOCOL.chacha20poly1305
  192. PROTOCOL.key
  193. PROTOCOL.krl
  194. PROTOCOL.mux
  195. readconf.c
  196. readconf.h
  197. README
  198. README.dns
  199. README.platform
  200. README.privsep
  201. README.tun
  202. readpass.c
  203. rijndael.c
  204. rijndael.h
  205. rsa.c
  206. rsa.h
  207. sandbox-capsicum.c
  208. sandbox-darwin.c
  209. sandbox-null.c
  210. sandbox-pledge.c
  211. sandbox-rlimit.c
  212. sandbox-seccomp-filter.c
  213. sandbox-solaris.c
  214. sandbox-systrace.c
  215. sc25519.c
  216. sc25519.h
  217. scp.1
  218. scp.c
  219. servconf.c
  220. servconf.h
  221. serverloop.c
  222. serverloop.h
  223. session.c
  224. session.h
  225. sftp-client.c
  226. sftp-client.h
  227. sftp-common.c
  228. sftp-common.h
  229. sftp-glob.c
  230. sftp-server-main.c
  231. sftp-server.8
  232. sftp-server.c
  233. sftp.1
  234. sftp.c
  235. sftp.h
  236. smult_curve25519_ref.c
  237. ssh-add.1
  238. ssh-add.c
  239. ssh-agent.1
  240. ssh-agent.c
  241. ssh-dss.c
  242. ssh-ecdsa.c
  243. ssh-ed25519.c
  244. ssh-gss.h
  245. ssh-keygen.1
  246. ssh-keygen.c
  247. ssh-keyscan.1
  248. ssh-keyscan.c
  249. ssh-keysign.8
  250. ssh-keysign.c
  251. ssh-pkcs11-client.c
  252. ssh-pkcs11-helper.8
  253. ssh-pkcs11-helper.c
  254. ssh-pkcs11.c
  255. ssh-pkcs11.h
  256. ssh-rsa.c
  257. ssh-sandbox.h
  258. ssh.1
  259. ssh.c
  260. ssh.h
  261. ssh1.h
  262. ssh2.h
  263. ssh_api.c
  264. ssh_api.h
  265. ssh_config
  266. ssh_config.5
  267. sshbuf-getput-basic.c
  268. sshbuf-getput-crypto.c
  269. sshbuf-misc.c
  270. sshbuf.c
  271. sshbuf.h
  272. sshconnect.c
  273. sshconnect.h
  274. sshconnect1.c
  275. sshconnect2.c
  276. sshd.8
  277. sshd.c
  278. sshd_config
  279. sshd_config.5
  280. ssherr.c
  281. ssherr.h
  282. sshkey.c
  283. sshkey.h
  284. sshlogin.c
  285. sshlogin.h
  286. sshpty.c
  287. sshpty.h
  288. sshtty.c
  289. survey.sh.in
  290. TODO
  291. ttymodes.c
  292. ttymodes.h
  293. uidswap.c
  294. uidswap.h
  295. umac.c
  296. umac.h
  297. utf8.c
  298. utf8.h
  299. uuencode.c
  300. uuencode.h
  301. verify.c
  302. version.h
  303. xmalloc.c
  304. xmalloc.h