ifix uninitialized buffer for getnameinfo on failure - geomyidae - A small C-based gopherd. Err bitreich.org 70 hgit clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/ URL:git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/ bitreich.org 70 1Log /scm/geomyidae/log.gph bitreich.org 70 1Files /scm/geomyidae/files.gph bitreich.org 70 1Refs /scm/geomyidae/refs.gph bitreich.org 70 1Tags /scm/geomyidae/tag bitreich.org 70 1README /scm/geomyidae/file/README.gph bitreich.org 70 1LICENSE /scm/geomyidae/file/LICENSE.gph bitreich.org 70 i--- Err bitreich.org 70 1commit bc06de10b6d279ef57ad0ba294610447bd2988fc /scm/geomyidae/commit/bc06de10b6d279ef57ad0ba294610447bd2988fc.gph bitreich.org 70 1parent f02d57cfae2c18951b665353b21aed02d29731a9 /scm/geomyidae/commit/f02d57cfae2c18951b665353b21aed02d29731a9.gph bitreich.org 70 hAuthor: Hiltjo Posthuma URL:mailto:hiltjo@codemadness.org bitreich.org 70 iDate: Wed, 29 Aug 2018 20:31:30 +0200 Err bitreich.org 70 i Err bitreich.org 70 ifix uninitialized buffer for getnameinfo on failure Err bitreich.org 70 i Err bitreich.org 70 iPOSIX says for getnameinfo: Err bitreich.org 70 i"Upon successful completion, getnameinfo() shall return the node and service Err bitreich.org 70 inames, if requested, in the buffers provided. The returned names are always Err bitreich.org 70 inull-terminated strings." Err bitreich.org 70 i Err bitreich.org 70 iHow I interpret it is on failure these buffers can be undefined, so make sure Err bitreich.org 70 ito clear them on failure. Err bitreich.org 70 i Err bitreich.org 70 iSigned-off-by: Christoph Lohmann <20h@r-36.net> Err bitreich.org 70 i Err bitreich.org 70 iDiffstat: Err bitreich.org 70 i M main.c | 6 ++++-- Err bitreich.org 70 i Err bitreich.org 70 i1 file changed, 4 insertions(+), 2 deletions(-) Err bitreich.org 70 i--- Err bitreich.org 70 1diff --git a/main.c b/main.c /scm/geomyidae/file/main.c.gph bitreich.org 70 i@@ -558,9 +558,11 @@ main(int argc, char *argv[]) Err bitreich.org 70 i } Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i- getnameinfo((struct sockaddr *)&clt, cltlen, clienth, Err bitreich.org 70 i+ if (getnameinfo((struct sockaddr *)&clt, cltlen, clienth, Err bitreich.org 70 i sizeof(clienth), clientp, sizeof(clientp), Err bitreich.org 70 i- NI_NUMERICHOST|NI_NUMERICSERV); Err bitreich.org 70 i+ NI_NUMERICHOST|NI_NUMERICSERV)) { Err bitreich.org 70 i+ clienth[0] = clientp[0] = '\0'; Err bitreich.org 70 i+ } Err bitreich.org 70 i Err bitreich.org 70 i if (!strncmp(clienth, "::ffff:", 7)) Err bitreich.org 70 i memmove(clienth, clienth+7, strlen(clienth)-6); Err bitreich.org 70 .