[Bug 257510] unstr does not produce a valid fortune file

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 30 Jul 2021 16:32:21 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257510

            Bug ID: 257510
           Summary: unstr does not produce a valid fortune file
           Product: Base System
           Version: 13.0-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: hubert.tournier@gmail.com

Created attachment 226804
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=226804&action=edit
Patch file to correct the issue

Overview:

While reimplementing the unstr command, I noticed that the original command,
when displaying a fortune file in the order specified in its datafile, does not
print the final '%' delimiter, which should end any fortune and any fortune
file.

Steps to Reproduce:

# cd /usr/share/games/fortune
# tail -1 freebsd-tips
%
# strfile -Co freebsd-tips
"freebsd-tips.dat" created
There were 134 strings
Longest string: 746 bytes
Shortest string: 39 bytes
# unstr freebsd-tips | tail -4
%
sh (the default Bourne shell in FreeBSD) supports command-line editing.  Just
``set -o emacs'' or ``set -o vi'' to enable it. Use "<TAB>" key to complete
paths.

Build Date & Hardware: 
Additional Builds and Platforms:

Any BSD version since 4.4. This is a 28 years old bug!

Correction:

Here's a patchfile to correct this in /usr/src/usr.bin/fortune/unstr/unstr.c

-- 
You are receiving this mail because:
You are the assignee for the bug.