Bug 27480

Summary: [PATCH] fixes to jot(1) from OpenBSD
Product: Base System Reporter: dd <dd>
Component: binAssignee: dd <dd>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description dd freebsd_committer freebsd_triage 2001-05-21 00:50:01 UTC
The attached patch fixes some overflows in jot(1) and syncs up to
OpenBSD a little.  Significant changes include:

        - use getopt
        - de-register
        - fix overflows in -b and -w options; old behavior:

                dima@hornet% jot -b `perl -e 'print "A" x 2000'` 5
                Segmentation fault (core dumped)
                dima@hornet% jot -w `perl -e 'print "A" x 2000'` 5
                Segmentation fault (core dumped)

          (this is my primary motivation for the patch)
        - use strlcpy and snprintf
        - check return values of the above
        - fix other gratuituos diffs to OpenBSD; not a complete sync,
          but better than nothing

Fix: I've sent this to -audit; it elicited comments about breaking K&R,
which I addressed, but no solid reviews.
How-To-Repeat:                 dima@hornet% jot -b `perl -e 'print "A" x 2000'` 5
                Segmentation fault (core dumped)
                dima@hornet% jot -w `perl -e 'print "A" x 2000'` 5
                Segmentation fault (core dumped)
Comment 1 Bruce Evans 2001-05-22 14:14:16 UTC
> The attached patch fixes some overflows in jot(1) and syncs up to
> OpenBSD a little.  Significant changes include:
> 
>         - use getopt
>         - de-register
>         - fix overflows in -b and -w options; old behavior:
>...
>         - use strlcpy and snprintf
>         - check return values of the above
>         - fix other gratuituos diffs to OpenBSD; not a complete sync,
>           but better than nothing

I would prefer to see the cleanups separately.  Especially the getopt
changes which merge getargs() into main() and rename av to argv.

> I've sent this to -audit; it elicited comments about breaking K&R,
> which I addressed, but no solid reviews.

I noticed only a couple of minor style problems (similar to ones in
the original code).

You've done more than enough time as a ports-only (?) committer and
should commit things more directly.  Reviews are good of course if
you can get them promptly.

Bruce
Comment 2 dima 2001-05-23 04:37:50 UTC
Bruce Evans <bde@zeta.org.au> writes:
> > The attached patch fixes some overflows in jot(1) and syncs up to
> > OpenBSD a little.  Significant changes include:
> > 
> >         - use getopt
> >         - de-register
> >         - fix overflows in -b and -w options; old behavior:
> >...
> >         - use strlcpy and snprintf
> >         - check return values of the above
> >         - fix other gratuituos diffs to OpenBSD; not a complete sync,
> >           but better than nothing
> 
> I would prefer to see the cleanups separately.  Especially the getopt
> changes which merge getargs() into main() and rename av to argv.

Separately from what?  The fixes for overflows?  If so, I think it's
appropriate to do it all in one commit; the overflows were fixed by
strcpy -> strlcpy fixes.  It would seem odd to fix two of the bugs in
one commit, and the rest in another one a few minutes later.  I
understand that it's nice to separate bugfixes from cleanups, but in
this case the bugs are fixed by cleaning up the code (more so than usual).

					Dima Dorfman
					dima@unixfreak.org
Comment 3 dd freebsd_committer freebsd_triage 2001-05-27 22:08:28 UTC
State Changed
From-To: open->analyzed

Committed my own patch. 


Comment 4 dd freebsd_committer freebsd_triage 2001-05-27 22:08:28 UTC
Responsible Changed
From-To: freebsd-bugs->dd

My MFC reminder.
Comment 5 dd freebsd_committer freebsd_triage 2001-07-19 08:57:49 UTC
State Changed
From-To: analyzed->closed

mfc'd