public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
From: "Lavrentiev, Anton (NIH/NLM/NCBI) [C]" <lavr@ncbi.nlm.nih.gov>
To: "cygwin-patches@cygwin.com" <cygwin-patches@cygwin.com>
Subject: RE: resolver //Was: [PATCH 3/7] Debug output to show both IP and port # in native b.o., a few little cosmetic improvements for consistency
Date: Mon, 17 Jan 2022 18:29:01 +0000	[thread overview]
Message-ID: <DM8PR09MB70952595CA9E93D575F033F9A5579@DM8PR09MB7095.namprd09.prod.outlook.com> (raw)

Hi Corinna,

> Other than that, the remaining patches look good, except, adding a short
> description what patch 7 does to the commit message would be great for
> later readers of the git log.

I resubmitted the patches with a little improvement and a better description
to the #7 (now #5) as requested.

While doing the code review afresh in there, I noticed a few more problems:

1.
minires-os-if.c on line 262 does this:
    262         ptr = NULL;
    263         break;

and then a bit later this:
    290   len = ptr - AnsPtr;

which makes the return value "len" to be a total nonsense (I think it should
return -1 in this case, but it's debatable).

2.
Also, "ptr" in the cygwin_query() function is not checked for buffer overrun
in the "done:" section of the code (after line 291), which is not good IMO.

3.
Lastly, at other places where "ptr" is checked for overrun (notably, in write_record()),
it can leave garbage in the unfilled portion of the answer buffer (because it still
advances "ptr" properly, to calculate the final "would-be" size of the response):
so if the return value is greater than the passed "AnsLength", the user cannot assume
that at least all AnsLength bytes were filled correctly.  They cannot actually assume
any "boundary" where the "Ans" buffer was actually stopped being updated.

Maybe "Ans" should be cleared upon entry?... But that would mean double-write of
the buffer in most of the use-cases (where no overflow actually occurs because of
an adequate size of the buffer).

Anton Lavrentiev
Contractor NIH/NLM/NCBI


             reply	other threads:[~2022-01-17 18:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-17 18:29 Lavrentiev, Anton (NIH/NLM/NCBI) [C] [this message]
2022-01-18 10:50 ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM8PR09MB70952595CA9E93D575F033F9A5579@DM8PR09MB7095.namprd09.prod.outlook.com \
    --to=lavr@ncbi.nlm.nih.gov \
    --cc=cygwin-patches@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).