Re: quiz: Fix multi-line questions (trailing newline)

2021-03-10 Thread Todd C . Miller
On Wed, 10 Mar 2021 22:49:13 -0500, Alex Karle wrote: > > This would now be clearer as: > > > > if (qlen > 0 && qp->q_text[qlen - 1] == '\\') { > > I agree this is clearer, but I think we'll need a `qlen = 0` > initialization up above the while loop if we go with this

Re: quiz: Fix multi-line questions (trailing newline)

2021-03-10 Thread Alex Karle
On Wed, Mar 10, 2021 at 02:03:33PM -0700, Todd C. Miller wrote: > On Wed, 10 Mar 2021 21:15:13 +0100, Christian Weisgerber wrote: > > > Right. Next iteration: > > Looks better, one minor nit inline. > > - todd My ok doesn't weigh much, but I wanted to chime in to say thanks for picking this

Re: quiz: Fix multi-line questions (trailing newline)

2021-03-10 Thread Todd C . Miller
On Wed, 10 Mar 2021 21:15:13 +0100, Christian Weisgerber wrote: > Right. Next iteration: Looks better, one minor nit inline. - todd > Index: quiz.c > === > RCS file: /cvs/src/games/quiz/quiz.c,v > retrieving revision 1.30 > diff

Re: quiz: Fix multi-line questions (trailing newline)

2021-03-10 Thread Christian Weisgerber
Todd C. Miller: > I don't think your use of qlen is safe since it is initialized > to zero. Specifically, it looks like "qp->q_text[qlen - 1]" > would be an out of bounds read. Should qlen be initialized > to strlen(qp->q_text) if qp->q_text != NULL? Right. Next iteration: Index: quiz.c

Re: quiz: Fix multi-line questions (trailing newline)

2021-03-09 Thread Todd C . Miller
On Tue, 09 Mar 2021 22:04:42 +0100, Christian Weisgerber wrote: > Thanks a lot for figuring this out! I finally got around to looking > at your patch. Once we have nul-terminated lines, appdstr() can > be replaced with realloc() and strlcat(). I don't think your use of qlen is safe since it is

Re: quiz: Fix multi-line questions (trailing newline)

2021-03-09 Thread Christian Weisgerber
Alex Karle: > Looking deeper, there is a bug in quiz(6) for datfiles with multi-line > answers. > > Specifically, the following quiz.db line: > > foo:\ > bar > > Is parsed into "foo:bar\n", which made it impossible to get right (since > the comparison was expecting a newline).

Re: quiz: Fix multi-line questions (trailing newline)

2021-02-24 Thread Alex Karle
Hi all, v2 below following some feedback from Christian (naddy@, thanks!). Only change is the malloc + strlcpy is replaced with a strdup. Thanks, Alex diff --git games/quiz/quiz.c games/quiz/quiz.c index 073c1700719..f6eac5027e8 100644 --- games/quiz/quiz.c +++ games/quiz/quiz.c @@ -110,7

quiz: Fix multi-line questions (trailing newline)

2021-02-22 Thread Alex Karle
Hi all, I was thrilled to find that the quiz for ed(1) commands, `function ed-command` (as referenced in The UNIX Programming Enviroment), existed in OpenBSD, but found that there was a bug where ~half of my correct answers were not accepted. Looking deeper, there is a bug in quiz(6) for