summaryrefslogtreecommitdiffstats
path: root/text-utils
Commit message (Collapse)AuthorAgeFilesLines
* tailf: Fix segmentation fault in tailf on 32 bitTobias Stoeckmann2016-07-141-2/+5
| | | | | | | | | | | | | tailf crashes with a segmentation fault when used with a file that is exactly 4GB in size due to an integer overflow between off_t and size_t: $ dd if=/dev/zero of=tailf.crash bs=1 count=1 seek=4294967295 $ tailf tailf.crash Segmentation fault $ _ Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* more: don't include ncurses.h, fix for non-widecharKarel Zak2016-06-031-5/+2Star
| | | | | | | | It seems our crazy widechar.h is in conflict with ncurses, but it seems that nothing in more.c requires anything from ncurses. All we need is probably <term.h>. Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: Fix various typosSebastian Rasmussen2016-05-312-4/+4
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* docs: Fix various typosSebastian Rasmussen2016-05-312-3/+3
| | | | Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* colcrt: avoid the command getting hung [afl]Sami Kerola2016-04-131-0/+7
| | | | | | | Some inputs make getwc(3) not to progress file descriptor and neither to report EILSEQ. Detect such situation and skip the bad input. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* docs: miscellaneous tiny tweaks of man pagesBenno Schulenberg2016-03-171-5/+5
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* misc: never cast void* from malloc(3) and friendsRuediger Meier2016-03-071-2/+2
| | | | | | | | | | Such cast could hide serious compiler warnings in case we are missing includes (e.g. <stdlib.h> or "xalloc.h"). See http://stackoverflow.com/questions/605845/do-i-cast-the-result-of-malloc Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* Merge branch 'master' of https://github.com/Rufflewind/util-linuxKarel Zak2016-03-071-3/+3
|\
| * hexdump: certain long options should not accept argumentsPhil Ruffwind2016-03-061-3/+3
| | | | | | | | | | | | | | | | As documented in the manual and the usage info, the long options --one-byte-char, --canonical, and --two-bytes-octal should not accept any arguments. Signed-off-by: Phil Ruffwind <rf@rufflewind.com>
* | misc: fix some includesRuediger Meier2016-02-291-1/+0Star
|/ | | | | | | | | features.h: any glibc header includes this already libgen.h: was unused there sys/uio.h: for writev(3p) sys/queue.h seems like it was never used Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* build-sys: disable unused parameter warnings for some test progsRuediger Meier2016-02-231-1/+1
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* build-sys: always add AM_CFLAGSRuediger Meier2016-02-231-1/+1
| | | | | | | | We were missing our nice compliler warnings for many programs and libs. See next commits how many trivial and non-trival warnings have to be fixed. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* lib: rename strmode() and setmode()Ruediger Meier2016-02-181-5/+5
| | | | | | On BSD they are part of the standard C library. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* colcrt: minor cosmetic changesKarel Zak2016-02-111-14/+35
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* colcrt: reimplementationSami Kerola2016-02-021-243/+176Star
| | | | | | | | | | This implementation aims to be easier to read, more robust dealing all sorts of unexpected inputs, and possibly even more correct. The correctness refers to last line handling this implementation does differently than the previous. With the previous last line that ended to EOF without \n was not printed. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: remove unnecessary compatibility layerKarel Zak2016-01-261-66/+41Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: remove libtermcap supportSami Kerola2016-01-262-91/+23Star
| | | | | | | | | | It is unlikely anyone is going to build this project on system where libtermcap is available. Fedora project obsoleted libtermcap 2007-12-12 in favour of ncurses. Debian made same move 2005. Reference: https://fedoraproject.org/wiki/Deprecated_packages Reference: https://www.debian.org/doc/manuals/debian-faq/ch-compat.en.html#s-termcap Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column: ignore non-printable charsKarel Zak2016-01-131-7/+36
| | | | | | | | | | | | | | | | | echo -e '\033[33mb\033[mXFoo\n\033[33mbar\033[mXFoo' | column -s X -t old version: b Foo bar Foo fixed version: b Foo bar Foo References: https://github.com/karelzak/util-linux/issues/252 Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/tty: Pass default width to get_terminal_width()Boris Egorov2016-01-061-3/+1Star
| | | | | | | | | | Almost any code calling get_terminal_width() checks returned width for non-positive values and sets it to some default value (say, 80). So, let's pass this default value directly to the function. [kzak@redhat.com: - get_terminal_width() refactoring] Signed-off-by: Karel Zak <kzak@redhat.com>
* line: keep stdin unbuifferedKarel Zak2015-12-021-0/+1
| | | | | | | | | | | | | | | $ printf 'a\nb\n' | echo $(./line) :: $(./line) broken version: a :: fixed version: a :: b Addresses: https://github.com/karelzak/util-linux/issues/236 Signed-off-by: Karel Zak <kzak@redhat.com>
* hexdump: fix a typo and tweak some wordings in the manpageBenno Schulenberg2015-11-091-5/+6
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* colcrt: allocate enough space for data moves [afl & asan]Sami Kerola2015-08-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | ==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>
* colcrt: avoid writing beyond array bound [afl & asan]Sami Kerola2015-08-101-0/+2
| | | | | | | | | | | | | | | 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>
* colcrt: use #define in place of magic constantsSami Kerola2015-08-091-11/+14
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: improve ugly macroKarel Zak2015-08-051-10/+17
| | | | | | no comment, just F*CK YOU to the original author of this crap... Signed-off-by: Karel Zak <kzak@redhat.com>
* tailf: fix open() return value check [coverity scan]Karel Zak2015-08-051-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* hexdump: fix man page (-x vs. default output)Karel Zak2015-07-301-4/+3Star
| | | | | Reported-by: Reuti <reuti@staff.uni-marburg.de> Signed-off-by: Karel Zak <kzak@redhat.com>
* tailf: deprecatedRuediger Meier2015-03-162-4/+16
| | | | | | | | | | | | 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>
* tailf: use size_t and fwrite()Karel Zak2015-03-051-18/+14Star
| | | | | | | 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>
* tailf: ensure file argument really is a fileSami Kerola2015-03-051-1/+2
| | | | | | | | | | 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>
* tailf: do not allow minus signed last lines argumentSami Kerola2015-03-051-11/+13
| | | | | | | | | | | 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>
* tailf: count last lines correctly at initial print outSami Kerola2015-03-051-41/+36Star
| | | | | | | | | 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>
* lib/colors: use libtinfo to check terminal capabilityKarel Zak2015-02-271-1/+1
| | | | | | | | | | | | | | | 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>
* colors: cleanup man pages, add hint to usage()Karel Zak2015-02-252-2/+5
| | | | | | | | cfdisk, fdisk, calm dmesg and hexdump Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: grammarize and harmonize the stat error messageBenno Schulenberg2015-02-022-3/+3
| | | | | | | | | 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>
* more: fix repeat search crashSami Kerola2015-01-281-0/+3
| | | | | | | | | 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>
* docs: restore minus symbols in long optsJ William Piggott2015-01-213-5/+5
| | | | Signed-off-by: J William Piggott <elseifthen@gmx.com>
* docs: remove obsolete and unneeded comments from man-page filesBenno Schulenberg2015-01-125-14/+10Star
| | | | | | | 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>
* ul: remove unexplained TERM=lpr overrideSami Kerola2015-01-071-9/+0Star
| | | | | | | 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>
* tailf: slice up the usage text for ease of translationBenno Schulenberg2015-01-061-10/+9Star
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* colcrt: slice up the usage text for ease of translationBenno Schulenberg2015-01-061-8/+8
| | | | | | Also use the standard macros for outputting it. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-0611-1/+42
| | | | | | | | | 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>
* more: fix compiler warningsKarel Zak2014-12-191-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* more: blacklist unsigned integer overflow [AddressSanitizer]Sami Kerola2014-12-191-4/+11
| | | | | | The mbrtowc() return values are overflowing by design. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* line: use util-linux conventionsSami Kerola2014-12-091-15/+49
| | | | | | | | 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>
* textual: improve error messagesSami Kerola2014-12-091-6/+4Star
| | | | | | | 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>
* hexdump: use 'll' format modifier instead of the non-standard 'q'.Natanael Copa2014-10-311-7/+9
| | | | | | | | | 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>
* ul: fix filter() indentationSami Kerola2014-10-201-85/+75Star
| | | | | | Content of the while() loop missed one indentation step. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: use usage() text element macrosSami Kerola2014-10-012-11/+6Star
| | | | | | | 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>
* textual: use manual tail usage() macroSami Kerola2014-10-015-1/+5
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>