24 Commits

Author SHA1 Message Date
Lorenzo Gatti
58eec2948f Fix memory corruption with invalid smush amount
https://github.com/cmatsuoka/figlet/issues/4
lorenzogatti commented on Oct 28, 2014:

Another case of buffer overrun in the same function, again for right to left
layout: smushing away more characters that are contained in the outputline[]
buffers, with STRCAT being passed an invalid pointer (past the end of an
outputline[] buffer).

How is it possible to smush more characters than the length of the buffer? A
single character can be wider than the current line, but smushamt() doesn't
limit the amount of smushing to the length of the current line. Enormous
amounts of smushing are possible with space-rich fonts, such as the Obanner
collection.

Fixed in smushamt() by limiting the range of the result.

Test case:

$ figlet -f obanner132.flf -R -x -o -p -w 77 "Banner, o Banner"

--

Original fix by Lorenzo Gatti, reworked by Claudio Matsuoka.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2015-05-10 18:25:58 -03:00
Claudio Matsuoka
89693cb2ab Initialize uninitialized string
Local string buffer was being operated without proper initialization, causing
wcslen() to operate on invalid values.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2015-05-10 18:25:16 -03:00
Claudio Matsuoka
3cd070553d Update changelog, version number and release date
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2012-05-30 10:57:47 -03:00
Claudio Matsuoka
eeaa125de6 Add environment variable FIGLET_FONTDIR
Environment variable FIGLET_FONTDIR can be used to set the path to search
for font files. This variable is used in the test script when FIGlet is
installed on a staging directory.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-25 23:44:08 -02:00
Claudio Matsuoka
0d2908b98c Don't use unitialized variable fontpath
Font path operations moved to FIGopen(), error messages changed to
use fontname.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-25 20:56:14 -02:00
Claudio Matsuoka
5a5d97a100 Fix kerning with UCS4 characters
Use outchr as the ouput character type (instead of char) when computing
kerning, to prevent corruption with tlf2 fonts

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-25 20:56:14 -02:00
Claudio Matsuoka
f4f94eacd4 Update version number and changelog
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-25 20:56:14 -02:00
Claudio Matsuoka
bcc3cecb4f Fix rendering corruption on multiline smushing
Fix output corruption on line breaks caused by a previous attempt to
fix invalid memory accesses when smushing at the start of the line.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-23 12:13:46 -02:00
Claudio Matsuoka
b320d67ce7 Refactor code to open font and control files
Reduce duplicate code by moving file opening code to the FIGopen()
function. This function is used to open font and control files, and
will be used to open multiple font files in ransom mode.

For code simplicity, DEFAULTFONTFILE is now defined without suffix.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-23 12:09:27 -02:00
Claudio Matsuoka
e38c680eab Document TLF font support and add infocode 5
Option -I5 lists supported file formats. If FIGlet is compiler with
TLF_FONTS defined, it will show tlf2 besides the always present flf2.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-16 19:57:19 -02:00
Claudio Matsuoka
92caff610b Use font file name without suffix in error message
If a bad font file name is specified, display only the font name
without suffix, otherwise only the .tlf suffix is displayed (if
TLF_FONTS is defined)

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-16 13:29:55 -02:00
Claudio Matsuoka
b139ccbd5f Version string and changelog updates
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-16 12:47:50 -02:00
Claudio Matsuoka
96756a169e Fix parameters of readfontchar()
Found by inspection, the absence of function prototypes cause the compiler
to not issue a warning about this problem.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-16 11:09:44 -02:00
Claudio Matsuoka
5f7350cae5 Add support to TLF font format
The TLF font format is used by TOIlet and is very similar to the FLF
font format, the only difference being the presence of UTF-8 encoded
Unicode characters. This patch adds TLF support to FIGlet if TLF_FONTS
is defined in Makefile.

When TLF_FONTS is defined, the internal character format is changed
to UCS-4 wide characters. System requirements are support to UTF-8
multibyte encoding, a font capable of displaying Unicode glyphs and an
implementation of C99 wchar.h.

Warning: UTF-8 characters are allowed as endmarks and sub-characters, but
not as a hardblank symbol.

Example:

$ fortune | ./figlet -fpagga
░█▀█░▀█▀░█▀█░█▀▀░▀█▀░█░█░░░█▀█░█▀▀░█▀▄░█▀▀░█▀▀░█▀█░▀█▀░░░█▀█░█▀▀
░█░█░░█░░█░█░█▀▀░░█░░░█░░░░█▀▀░█▀▀░█▀▄░█░░░█▀▀░█░█░░█░░░░█░█░█▀▀
░▀░▀░▀▀▀░▀░▀░▀▀▀░░▀░░░▀░░░░▀░░░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀░▀░░▀░░░░▀▀▀░▀░░
░█▀▀░█░█░█▀▀░█▀▄░█░█░▀█▀░█░█░▀█▀░█▀█░█▀▀░░░▀█▀░█▀▀░░░█▀▀░█▀▄░█▀█░█▀█░░░
░█▀▀░▀▄▀░█▀▀░█▀▄░░█░░░█░░█▀█░░█░░█░█░█░█░░░░█░░▀▀█░░░█░░░█▀▄░█▀█░█▀▀░░░
░▀▀▀░░▀░░▀▀▀░▀░▀░░▀░░░▀░░▀░▀░▀▀▀░▀░▀░▀▀▀░░░▀▀▀░▀▀▀░░░▀▀▀░▀░▀░▀░▀░▀░░░▀░
░░░░░░░░░░░░░░░▀█▀░█░█░█▀▀░█▀█░█▀▄░█▀█░█▀▄░█▀▀
░░░░░▄▄▄░▄▄▄░░░░█░░█▀█░█▀▀░█░█░█░█░█░█░█▀▄░█▀▀
░░░░░░░░░░░░░░░░▀░░▀░▀░▀▀▀░▀▀▀░▀▀░░▀▀▀░▀░▀░▀▀▀
░█▀▀░▀█▀░█░█░█▀▄░█▀▀░█▀▀░█▀█░█▀█
░▀▀█░░█░░█░█░█▀▄░█░█░█▀▀░█░█░█░█
░▀▀▀░░▀░░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀▀▀░▀░▀

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-16 10:53:05 -02:00
Claudio Matsuoka
5b020c2272 Updated license to 3-clause BSD
License change was discussed in the mailing list and authors agreed
to use a non-restrictive license as the AFL mandated redistribution
of source code with each copy of the binary, and could also conflict
with the GPL license.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-12 14:03:50 -02:00
Claudio Matsuoka
c4a2f0db58 Updated version number and release date
Updated to version 2.2.3, release date 12 January 2011, and also add self
to author list with current year in Copyright notice.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-12 11:01:21 -02:00
Claudio Matsuoka
3635c3c5b4 Set version number to 2.2.3
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-12 00:35:48 -02:00
Claudio Matsuoka
d971045702 Update version number and changelog file
List current changes to the CHANGES file and call this version 2.3.
The version and date must be updated in several places before the
final release, including the FAQ and all man pages.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-12 00:27:50 -02:00
Claudio Matsuoka
6b41034f2f Address Turbo C warnings
Same case as before, return from main() using return instead of exit().

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-11 19:47:09 -02:00
Claudio Matsuoka
a2d9196f41 Address unitialized variable compiler warnings
Either initialize unitialized variables to sensible values, or supress
the warning in case the variable is always correctly initialized.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-11 17:14:16 -02:00
Claudio Matsuoka
caf8b1fcfd Fix memory violation when smushing at line start
Smushing characters at the line start can cause the next character to
be copied to an offset before the start of the line buffer. In this
case, add an offset to source and copy to a valid destination position.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-11 10:59:54 -02:00
Micah Cowan
634ec7e6c8 Fix behavior of JIS0201 SHIFT-OUT and SHIFT-IN
By Micah Cowan: "the meanings of the SHIFT-OUT (0x0E) and SHIFT-IN
(0x0F) seem to be reversed: SHIFT-OUT is intended to invoke G0 into GL,
and SHIFT-IN to invoke G1 into GR; however, the command

  $ printf 'Hell\x0Er' | figlet

appears to cause figlet to interpret the final "r" as... an "r", whereas

  $ printf 'Hell\x0Fr' | figlet

causes figlet to interpret the final "r" to be interpreted as SMALL
LETTER o WITH GRAVE ACCENT. I would expect exactly the opposite results.
A quick look at iso2022() seems to verify that character code 14 is
invoking G0 to GL, rather than G1."

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-10 17:07:59 -02:00
Claudio Matsuoka
27cd08716a Address compiler warnings
Add missing headers, remove unused variables, specify implicit types.
Ensure compatibility with ancient systems is maintained.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-10 08:04:29 -02:00
Claudio Matsuoka
47c9d2db33 Import FIGlet 2.2.2
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2011-01-10 07:37:04 -02:00