summaryrefslogtreecommitdiffstats
path: root/text-utils/colcrt.c
Commit message (Collapse)AuthorAgeFilesLines
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-2/+2
| | | | | | | | | changed in include/c.h and applied via sed: sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c") sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c") Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-271-2/+1Star
| | | | | | | | | | | | Consolidate --help and --version descriptions. We are now able to align them to the other options. We changed include/c.h. The rest of this patch was generated by sed, plus manually setting the right alignment numbers. We do not change anything but white spaces in the --help output. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: cosmetics, remove argument from usage(FILE*)Ruediger Meier2017-06-261-3/+4
| | | | | | | | | | | | | | This patch is trivial and changes nothing, because we were always using usage(stdout) Now all our usage() functions look very similar. If wanted we could auto-generate another big cosmetical patch to remove all the useless "FILE *out" constants and use printf and puts rather than their f* friends. Such patch could be automatically synchronized with the translation project (newlines!) to not make the translators sick. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-02-201-1/+1
| | | | | | | | | | text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer Since many 'struct option' has used zero as NULL make them more readable in same go by reindenting, and using named argument requirements. Reference: https://lwn.net/Articles/93577/ Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* build-sys: fix compilation with ncurses and uClibc or musl libcCarlos Santos2017-01-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Compiling util-linux with musl and uClibc-ng toolchains when wide-char support is not enabled in ncurses results in compilation failures with the following message: error: two or more data types in declaration specifiers #define wchar_t char The problem occurs because util-linux #defines its own wchar_t (as char) when configured without widechar support. This conflicts with definition of wchar_t contained in stddef.h. This error can be reproduced running "<toolchain-cc -o test test.c" with the following test program: #include <ctype.h> #define wchar_t char #include <stddef.h> int main() { return 0; } The only way to avoid the problem it to reorder the inclusion of headers in some files under the text-utils directory. Addresses: http://autobuild.buildroot.net/results/3a2f228e0fa7b5cc28a13d49f48f1a6aef8d9d7a http://autobuild.buildroot.net/results/99e96069f652d511c6212a5bb6be29e68fb1747c http://autobuild.buildroot.net/results/2dc5721aef93b7b410153bafad78248fac3db941 http://autobuild.buildroot.net/results/8a9e197ba7a292b18f8c0c36dca974685556a38a Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
* Use --help suggestion on invalid optionKarel Zak2016-12-191-1/+1
| | | | | | | | The current default is to print all usage() output. This is overkill in many case. Addresses: https://github.com/karelzak/util-linux/issues/338 Signed-off-by: Karel Zak <kzak@redhat.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>
* 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>
* 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>
* 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-061-0/+4
| | | | | | | | | 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>
* textual: use manual tail usage() macroSami Kerola2014-10-011-0/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: use version printing macro everywhereSami Kerola2014-10-011-3/+1Star
| | | | | | | 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>
* textual: spell and encode the name of Arkadiusz Miƛkiewicz correctlyBenno Schulenberg2013-02-061-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* mark expected fallthrough for static analysersKarel Zak2012-09-071-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* text-utils: verify writing to streams was successfulSami Kerola2012-04-041-2/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* colctr: use long options and clean coding styleSami Kerola2011-06-011-26/+64
| | | | | | This commit introduces help & version options. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* replace bcopy,bzero,index and rindexDaniel Mierswa2009-08-171-2/+2
| | | | | | | | | Those 4 functions are marked as LEGACY in POSIX.1-2001 and removed in POSIX.1-2008. Replaced with memmove,memset,strchr and strrchr. Signed-off-by: Daniel Mierswa <impulze@impulze.org>
* Imported from util-linux-2.11b tarball.Karel Zak2006-12-071-1/+1
|
* Imported from util-linux-2.10s tarball.Karel Zak2006-12-071-78/+101
|
* Imported from util-linux-2.10f tarball.Karel Zak2006-12-071-17/+27
|
* Imported from util-linux-2.9v tarball.Karel Zak2006-12-071-1/+10
|
* Imported from util-linux-2.9i tarball.Karel Zak2006-12-071-3/+4
|
* Imported from util-linux-2.8 tarball.Karel Zak2006-12-071-10/+0Star
|
* Imported from util-linux-2.7.1 tarball.Karel Zak2006-12-071-12/+14
|
* Imported from util-linux-2.2 tarball.Karel Zak2006-12-071-0/+251