Commit Graph

389 Commits

Author SHA1 Message Date
Benno Schulenberg e8cf378e48 hexdump: fix a typo and tweak some wordings in the manpage
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-11-09 10:03:58 +01:00
Sami Kerola 70e3fcf293 colcrt: allocate enough space for data moves [afl & asan]
==2807==ERROR: AddressSanitizer: global-buffer-overflow on address 0x0000013a31f0 at pc 0x0000004e3047 bp 0x7fffcb7df8d0 sp 0x7fffcb7df8c8
READ of size 4 at 0x0000013a31f0 thread T0
    #0 0x4e3046 in move /home/src/util-linux/text-utils/colcrt.c:309:13
    #1 0x4e25b1 in pflush /home/src/util-linux/text-utils/colcrt.c:264:3
    #2 0x4e246d in colcrt /home/src/util-linux/text-utils/colcrt.c:157:4
    #3 0x4e17d4 in main /home/src/util-linux/text-utils/colcrt.c:141:3
    #4 0x7fb0cb2ee60f in __libc_start_main (/usr/lib/libc.so.6+0x2060f)
    #5 0x4362c8 in _start (/home/src/util-linux/colcrt+0x4362c8)

0x0000013a31f0 is located 0 bytes to the right of global variable 'page' defined in 'text-utils/colcrt.c:73:9' (0x1380b40) of size 140976
SUMMARY: AddressSanitizer: global-buffer-overflow /home/src/util-linux/text-utils/colcrt.c:309 move

And another crash:

==4578==ERROR: AddressSanitizer: global-buffer-overflow on address 0x0000013a3d24 at pc 0x0000004e2510 bp 0x7ffc9257b0e0 sp 0x7ffc9257b0d8
READ of size 4 at 0x0000013a3d24 thread T0
    #0 0x4e250f in colcrt /home/src/util-linux/text-utils/colcrt.c:218:8
    #1 0x4e17d4 in main /home/src/util-linux/text-utils/colcrt.c:141:3
    #2 0x7fe0ac94160f in __libc_start_main (/usr/lib/libc.so.6+0x2060f)
    #3 0x4362c8 in _start (/home/src/util-linux/colcrt+0x4362c8)

0x0000013a3d24 is located 8 bytes to the right of global variable 'page' defined in 'text-utils/colcrt.c:73:9' (0x1381240) of size 142044
SUMMARY: AddressSanitizer: global-buffer-overflow /home/src/util-linux/text-utils/colcrt.c:218 colcrt

Reported-by: Alaa Mubaied <alaamubaied@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-08-10 21:48:42 +01:00
Sami Kerola d883d64d96 colcrt: avoid writing beyond array bound [afl & asan]
text-utils/colcrt.c:205:10: runtime error: index -1 out of bounds for type 'wchar_t [133]'
SUMMARY: AddressSanitizer: undefined-behavior text-utils/colcrt.c:205
=================================================================
==2357==ERROR: AddressSanitizer: global-buffer-overflow on address 0x0000013811b0 at pc 0x0000004e2514 bp 0x7ffdf6ba4450 sp 0x7ffdf6ba4448
READ of size 4 at 0x0000013811b0 thread T0
    #0 0x4e2513 in colcrt /home/src/util-linux/text-utils/colcrt.c:213:8
    #1 0x4e17d4 in main /home/src/util-linux/text-utils/colcrt.c:139:3
    #2 0x7fb77236960f in __libc_start_main (/usr/lib/libc.so.6+0x2060f)
    #3 0x4362c8 in _start (/home/src/util-linux/colcrt+0x4362c8)

Reported-by: Alaa Mubaied <alaamubaied@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-08-10 21:48:38 +01:00
Sami Kerola 3a41cdd7b5 colcrt: use #define in place of magic constants
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-08-09 18:59:52 +01:00
Karel Zak 8f2a465073 more: improve ugly macro
no comment, just F*CK YOU to the original author of this crap...

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-05 13:09:12 +02:00
Karel Zak c6556f7ca8 tailf: fix open() return value check [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-05 11:55:56 +02:00
Karel Zak 35d8592cd4 hexdump: fix man page (-x vs. default output)
Reported-by: Reuti <reuti@staff.uni-marburg.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-30 11:49:15 +02:00
Ruediger Meier 3f8478a71c tailf: deprecated
We want to remove it in 2 years, March 2017.

See discussion "tailf, really needed?"
http://thread.gmane.org/gmane.linux.utilities.util-linux-ng/10967

[kzak@redhat.com: - move warning to usage()]

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-16 14:26:47 +01:00
Karel Zak e1f7791c81 tailf: use size_t and fwrite()
Let's use size_t for number of output lines and use fwrite() rather
than while() { putchar() };

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-05 11:11:53 +01:00
Sami Kerola 9195eca64d tailf: ensure file argument really is a file
The tailf(1) never worked very well with block or character devices,
sockets, fifos and such.  Now after mmap() is used to find last lines
even the little command used to work for example pipes is broken, so test
the tailf is asked to follow a file and when not fail.  That said
symlinks are OK, as long they point to a file.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-03-05 10:31:18 +01:00
Sami Kerola 16d3d9a04d tailf: do not allow minus signed last lines argument
Before mmap() the command behavior was not completely correct, as
demonstrated below, and after the mmap() it tried to print some eighteen
quintillion lines.

$ tailf -n-1 x
tailf: cannot allocate 18446744073709543424 bytes: Cannot allocate memory

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-03-05 10:31:18 +01:00
Sami Kerola a260b21bdb tailf: count last lines correctly at initial print out
When last lines happen to be greater than string buffer size for fgets()
the number of printed lines resulted to too few.  To avoid miscounts due
insufficient buffer size use mmap() to map the whole file and rewind
until requested number of new lines is found.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-03-05 10:31:18 +01:00
Karel Zak 4310faf950 lib/colors: use libtinfo to check terminal capability
The current implementation assumes that all terminals supports colors
and users are forcet to use terminal-colors.d/ to disable colors for
some terminals.

This patch checks for maximal supported colors for the current
terminal and colors are automatically disabled for terminals like
vt100.

The patch moves lib/colors.c from libcommon.la to libtcolors.la to
avoid collisions with another utils.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-27 13:57:34 +01:00
Karel Zak 5d51dc2a7f colors: cleanup man pages, add hint to usage()
cfdisk, fdisk, calm dmesg and hexdump

Signed-off-by: Karel Zak <kzak@redhat.com>

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-25 12:40:06 +01:00
Benno Schulenberg fc14ceba5e textual: grammarize and harmonize the stat error message
The message "stat failed %s" seems to say that stat() failed to
do something, or failed to pass a test, but of course it means
that the statting of something failed.  So say so.  Also make
two very similar messages equal to this one.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-02-02 11:27:10 +01:00
Sami Kerola bc1ed33881 more: fix repeat search crash
Repeating a search for a pattern that did not found made more(1) to
crash.  To reproduce 'more /etc/services' and search for 'doom'; you will
find a service in port 666 - pressing '.' after that result used to cause
core dump.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-28 08:27:45 +01:00
J William Piggott b06c1ca6f8 docs: restore minus symbols in long opts
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2015-01-20 18:15:30 -05:00
Benno Schulenberg 3a60b1c26b docs: remove obsolete and unneeded comments from man-page files
Transform some of them into copyright lines.
Also fix three header lines and snip some trailing whitespace.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-12 11:03:26 +01:00
Sami Kerola 97d8f180b6 ul: remove unexplained TERM=lpr override
The FIXME item has been in place since 2011-04-30, and the code has never
made sense, so remove it.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-07 21:57:53 +00:00
Benno Schulenberg 331d255261 tailf: slice up the usage text for ease of translation
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:47:25 +01:00
Benno Schulenberg 5f55b39e58 colcrt: slice up the usage text for ease of translation
Also use the standard macros for outputting it.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:44:24 +01:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
This adds a concise description of a tool to its usage text.

A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:27:38 +01:00
Karel Zak 2e28ebff99 more: fix compiler warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-12-19 14:34:03 +01:00
Sami Kerola 4d9a1969f7 more: blacklist unsigned integer overflow [AddressSanitizer]
The mbrtowc() return values are overflowing by design.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 11:32:38 +01:00
Sami Kerola c2e1ebbe84 line: use util-linux conventions
This change add --help and --version print outs, checking at exit the
stdout write was successful, and as a minor thing the command is made to
use wide char functions to read and write inputs.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-09 09:19:25 +01:00
Sami Kerola 338a6bc55b textual: improve error messages
Use error printing facilities that add command name in front of the error
message, and add explanation that is part of existing translations.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-09 09:19:22 +01:00
Natanael Copa 7235e70391 hexdump: use 'll' format modifier instead of the non-standard 'q'.
The printf(3) man page says about 'q':
("quad". 4.4BSD and Linux libc5 only. Don't use.) This is a synonym for ll.

This fixes hexdump with musl libc.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
2014-10-31 10:39:18 +01:00
Sami Kerola d07b223788 ul: fix filter() indentation
Content of the while() loop missed one indentation step.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-20 14:07:20 +02:00
Sami Kerola db433bf737 textual: use usage() text element macros
Translating these text elements should happen only once, which is
more likely when the text macros are used properly.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:26 +02:00
Sami Kerola a587cc5520 textual: use manual tail usage() macro
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:24 +02:00
Sami Kerola f627750083 textual: use version printing macro everywhere
Only mount, umount, and blkid remains not using the macro because they
are print also library references.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:23 +02:00
Sami Kerola bf60e9f12d hexdump: remove deprecation message
Message 'calling hexdump as od has been deprecated in favor of GNU
coreutils od' has informed the hexdump not to be used like that for three
and half years, and five releases.  It is time to get rid of notice.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:12 +02:00
Sami Kerola 7d2600e2d0 docs: update deprecation banners
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:11 +02:00
Benno Schulenberg 1d23119072 textual: remove some inconsistent periods from error messages
While doing so, also improve translatability and some wordings.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-08-11 14:51:54 +02:00
Steven Honeyman 1b19ea31a3 docs: fix inconsistencies in man pages
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-06 14:50:20 +02:00
HUANG Wei 82233c2a0a hexdump: Fix parse format of "byte count without repetition count" 2014-08-06 12:20:18 +08:00
Lauri Nurmi 140d91471d more: replace ad-hoc support for plurals with gettext plurals. 2014-07-28 11:46:59 +02:00
Benno Schulenberg 07990fdcd4 docs: bring several man pages closer to standard formatting
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-16 12:03:25 +02:00
Benno Schulenberg 1f94a78ce8 docs: improve formatting and wording of a few man pages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-14 16:21:34 +02:00
Karel Zak ee312c654b docs: fix "behaviour" vs. "behavior"
Sometimes we use "behaviour" and "behavior" in the same text, let's
use "behavior" only everywhere.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1011068
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-06 09:49:35 +02:00
Karel Zak cb45354ec6 build-sys: add BUILD_{COL,COLCRT,COLRM,COLUMN,HEXDUMP,REV,TAILF}
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-21 14:09:43 +02:00
Karel Zak 052e512a64 hexdump: add --color to the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-13 12:13:02 +02:00
Karel Zak 58ce71e63e hexdump: use new colors API
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-13 12:09:03 +02:00
Sami Kerola acb5f9b56e column: inform user when multibyte conversion error occurs
The column(1) read input until conversion error, and used incomplete
input when outputing, that made at least me to wonder where the rest
disappeared without explanation.  IMHO it is better to fail immediately
rather than do only half of the task.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-07 11:28:48 +02:00
Benno Schulenberg aa06617f6e textual: remove square brackets from around three dots
Also improve some option descriptions here and there.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-05-06 11:12:13 +02:00
Karel Zak b6a8cc0130 Merge branch 'pg-manual-page-long-options' of https://github.com/jaalto/util-linux
* 'pg-manual-page-long-options' of https://github.com/jaalto/util-linux:
  pg.1: Move (plus) options near (minus) option at the beginning
  pg.1: Add -h, --help, -V, --version
2014-04-01 11:37:06 +02:00
Karel Zak 60ec67ff4e lib/colors: add info to man pages, add terminal-colors.d.5
Co-Author: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 10:05:32 +01:00
Ondrej Oprala d0c9ddc3cc lib/colors: check for /etc/terminal-colors.d/[util].disable
[kzak@redhat.com: - move paths to pathnames.h,
                  - use static path buffer]

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 09:38:09 +01:00
Benno Schulenberg 01cc21f5b6 docs: fix two command representations in the man page of more
The previous-file command is not :P but :p, and the back-to-where
command is not an acute accent but an apostrophe.  Also condense
some of the descriptions and remove some useless comments.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-03-04 13:52:14 +01:00
Ondrej Oprala 3bf7ede997 hexdump: color unit may now be longer than the corresponding format unit
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-03-04 12:48:59 +01:00