While investigating a bug report with "install-info" I was testing
with the --calign and --align options. It was reported privately
that certain uses of these could lead to buffer overflows or division
by zero errors.
These are documented in the help message as follows:
--align=COL start description of new entries at column COL.
--calign=COL format second and subsequent description lines to
start at column COL.
This matches what is stated in NEWS, for Texinfo 4.12 (2008-04-20):
--align COL: start description at column COL.
--calign COL: start continuation lines in description at COL.
This gives us the clue that the "c" in "calign" was supposed to stand for
continuation.
However: this contradicts a comment in the source code, which implies that
the 'calign' value is used for the FIRST line of the desciption, and 'align'
is used for subsequent lines:
/* Indent all ENTRIES according to some formatting options.
CALIGN_CLI is the starting column for the first line of the description.
ALIGN_CLI is the starting column for all subsequent lines of the
description. MAXWIDTH_CLI is the number of columns in the line.
When CALIGN_CLI, ALIGN_CLI, or MAXWIDTH_CLI is -1, choose a sane default. */
The behaviour of the program matches the comment in the source code
(although with the small amount of testing I did, these options seemed
quite buggy).
The manual in texinfo.texi also has it this way around:
‘--align=COLUMN’
Specifies the column that the second and subsequent lines of menu
entry's description will be formatted to begin at. The default for
this option is ‘35’. It is used in conjunction with the
‘--max-width’ option. COLUMN starts counting at 1.
‘--calign=COLUMN’
Specifies the column that the first line of menu entry's
description will be formatted to begin at. The default for this
option is ‘33’. It is used in conjunction with the ‘--max-width’
option. When the name of the menu entry exceeds this column,
entry's description will start on the following line. COLUMN
starts counting at 1.
Apart from a minor edit, the text in the comment and the manual comes
from 2008, in this commit:
commit b9e0c3d71835b959c0cb6307fced71b692e95947
Author: Karl Berry <[email protected]>
Date: 2008-01-02 01:36:33 +0000
install-info and Debian compatibility
git-svn-id: svn://127.0.0.1/svn_repo/texinfo/trunk@2283
39fee189-59d7-47db-b5d4-205258b72aed
diff --git a/texinfo/ChangeLog b/texinfo/ChangeLog
index ab050941ad..23dfbebad0 100644
--- a/texinfo/ChangeLog
+++ b/texinfo/ChangeLog
@@ -1,3 +1,39 @@
+2008-01-02 Karl Berry <[email protected]>
+
+ * install-info/, install-info/tests/: new subdirectories.
+ * util/Makefile.am: move install-info stuff to its own dir, with tests.
+ * configure.ac,
+ * Makefile.am (SUBDIRS): take care of new dirs.
+ * doc/Makefile.am (install-info.1): new source location for man page.
+ * po/POTFILES.in: update source list.
+
+2008-01-02 Ben Asselstine <[email protected]>
+
+ * install-info/install-info.c: much work toward Debian compatibility.
+ (line_data): new member num_sections to add; change type of
+ add_entries_before.
+ (spec_entry): new members missing_name, missing_description,
+ missing_basename.
+ (longopts): new options --name, --menuentry, --description,
+ --no-indent, --keep-old, --maxwidth, --max-width,
+ --section-regex, --dry-run.
+ (remove_empty_sections, add_entries_into_all_matching_sections,
+ keep_old_flag, indent_flag,
+ order_new_sections_alphabetically_flag): new globals.
+ (print_help): list new options.
+ (output_dirfile): count sections added, and possibly sort them.
+ (parse_input): handle delete_flag.
+ (parse_dir_file): write the end of the last node.
+ (mark_entry_for_deletion, adjust_column, format_entry,
+ split_entry, reformat_new_entries, add_missing_basenames,
+ add_missing_names, add_missing_descriptions,
+ munge_old_style_debian_options): new fns.
+ (main): new variables calign, align, maxwidth,
+ entries_to_add_from_file; munge per debian if needed; handle new
+ options.
+ (compare_entries_text): use mbsncasecmp.
+ * doc/texinfo.txi (Invoking install-info): mention the new options.
+
2008-01-01 Karl Berry <[email protected]>
* info/info.c (info_short_help): break help string into smaller
This change was sent in this email:
From: Ben Asselstine
Subject: [PATCH] Add compatibility with Debian's install-info
Date: Tue, 1 Jan 2008 19:30:15 -0500
https://lists.gnu.org/archive/html/bug-texinfo/2008-01/msg00003.html
The --help text was added later, in commit 458ebfe3b344 in 2012:
2012-12-31 Karl Berry <[email protected]>
* install-info/install-info.c (): mention
--add-once, --align, --calign, --maxwidth, --max-width,
inadvertently omitted when implemented.
Also don't mention removals working with --entry.
Report from Benno Schulenberg, 26 Dec 2012 19:34:40.
I understand that these options came in to establish compatibility with
an install-info program from Debian (here is a thread from 2006 about it:
https://lists.gnu.org/archive/html/bug-texinfo/2006-05/msg00031.html).
Earlier mail agrees that it was for continuation lines (agreeing with
--help and NEWS, but disagreeing with texinfo.texi, program behaviour,
and comments in the source code). Here is an email from Norbert Preining
in 2007 which says the options were the other way around in Debian
install-info:
> Options in Debian install-info NOT in GNU
> --align=nnn [deprecated]
> Specifies that the first line of the description should be
> indented at least nnn characters; extra spaces will be added as
> required. If necessary because of the length of the dir menu
> entry details it may be offset more. The default is 27.
>
> --calign=nnn [deprecated]
> Specifies that the second and subsequent lines of the descrip-
> tion should be indented at least nnn characters. The default is
> 29.
>
> --maxwidth=nnn [deprecated]
> Specifies that the maximum width for the Info file is nnn. This
> is used when wordwrapping the descriptive text. The default is
> 79.
https://lists.debian.org/debian-dpkg/2007/05/msg00056.html
So based on this, --calign WAS supposed to be for subsequent lines, just the
implementation in GNU install-info got them the wrong way around. The --help
message and text in NEWS matched was supposed to be the behaviour in Debian
install-info.
(--align and --calign do not appear to be tested anywhere under
install-info/tests.)
In the referenced email from 2006, it was proposed that these options
be removed from the program:
The --align, --calign and --maxwidth options do not exist. They were
already ignored and dispalyed a warning indicating they were deprecated
(this was already the case before Sarge). I think they can be dropped.
https://lists.debian.org/debian-dpkg/2006/04/msg00026.html?pow_referer=
(If only this had been acted upon, we wouldn't have this to sort out 20
years later. Presumably these options are hardly ever used, otherwise
the contradiction would have been noticed earlier.)
This email from 2002 contains what looks like a release notice stating
that --calign and --align were ignored:
> dpkg (1.10) unstable; urgency=low
> ...
> * several install-info cleanups:
> * Move /usr/info/dir to /usr/share/info/dir. Closes: #67174.
> * If /usr/share/info doesn't exist, print a message saying so,
> instead of the confusing "couldn't lock" error. Closes: #2531.
> * If /usr/share/info/dir doesn't exist, or is empty, try to copy the
> backup from /var/backups/infodir.bak. Closes: #121309.
> * Add a --remove-exactly option, and allow for relative filenames.
> Closes: #92650.
> * Use the section from the .info file if --section is not given.
> Closes: #76100.
> * Error messages now include the filename being processed.
> Closes: #66735
> * /usr/share/info/dir now has it's entries formatted to even widths.
> Closes: #11228
> * --calign|--align|--maxwidth are now ignored.
https://lists.debian.org/debian-dpkg/2002/06/msg00216.html
I did not get to the bottom of why the options were deprecated or why
they were re-implemented for GNU install-info. I don't know what the
history is of why there were two programs - one message I read said
that Debian install-info was older
(https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=81232#10).
I found a few more old Debian bug tracker issues about the formatting
of dir descriptions, but nothing definitive about these options in particular:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=11228
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=167379
* * *
Does anyone have any more information, or opinions on what should be
done with these options?
The immediate problem is that there are bugs with these options. (For
example, in the following code:
outstr = xmalloc (width
+ (desc_len + width) / (width - align) * width * 2 * sizeof (char));
- if width is equal to align (--align argument), there is a division by zero.
Likewise there are potential buffer overflows if one of the align options
is given a value that is longer than the normal length of a line.)
So the easy option for me would be to make these options do nothing.