Karel Zak [Thu, 30 Mar 2017 10:10:01 +0000 (12:10 +0200)]
zramctl: make mm_stat parser more robust
Let's fallback to attribute files if mm_stat file is incomplete. It
should not happen, but I have seen RHEL7 kernel where is no
num_migrated/pages_compacted attribute...
Karel Zak [Mon, 27 Mar 2017 12:54:39 +0000 (14:54 +0200)]
agetty: fix characters reorder in login prompt
The current agetty uses TIOCSTI ioctl to return already read chars
from login name back to the terminal (without read() before
tcsetattr() we will lost data already written by user). The ioctl
based solution is fragile due to race -- we can return chars when
terminal already contains another new chars. The result is reordered
chars in login name.
The solution is to use extra buffer for already read data.
Reported-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Fri, 24 Mar 2017 10:59:57 +0000 (11:59 +0100)]
Merge branch '2017wk11' of git://github.com/kerolasa/lelux-utiliteetit
* '2017wk11' of git://github.com/kerolasa/lelux-utiliteetit:
blkid: add control struct
blkid: simplify version option handling
tests: add static keyword where needed [smatch scan]
tests: do not use plain 0 as NULL [smatch scan]
libsmartcols: fix test variable shadowing
It is possible to perform out of boundary read accesses due to
insufficient boundary checks in probe_hfsplus.
The first issue occurs if the leaf count in a B-node is too
small. The second happens while parsing a unicode description which
is longer than 255 UTF-8 characters. The length is stored in a 16 bit
integer, but the array in the struct is limited to 255 * 2, which is
in sync with Apple's Open Source HFS+ implementation (HFSUniStr255).
Sami Kerola [Sun, 5 Mar 2017 21:02:53 +0000 (21:02 +0000)]
libsmartcols: fix test variable shadowing
libsmartcols/samples/fromfile.c:57:16: warning: declaration of 'flags'
shadows a global declaration [-Wshadow]
libsmartcols/samples/fromfile.c:29:33: note: shadowed declaration is here
libsmartcols/samples/fromfile.c:101:8: warning: declaration of 'flags'
shadows a global declaration [-Wshadow]
Sami Kerola [Sun, 5 Mar 2017 20:52:25 +0000 (20:52 +0000)]
blkid: add messages to translations
Without obvious reason blkid has managed to be part of this project for
pretty long time without getting translations. Lets change that. In same
go use the usual error printing facilities instead of fprintf(stderr, ...);
[kzak@redhat.com: - use errtryh(),
- cleanup "unsupported output format"]
Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
Sami Kerola [Sun, 5 Mar 2017 20:52:24 +0000 (20:52 +0000)]
blkid: add curly braces to do-while statement
Some say people read do-while statements are easily as while statements and
get wrong impression. This happens because do-whiles are not common.
Adding braces should make it easier to read the code.
Reference: http://www.spinics.net/lists/linux-kernel-janitors/msg02018.html Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Sami Kerola [Sun, 5 Mar 2017 20:52:23 +0000 (20:52 +0000)]
libblkid: ensure uninitialized variable is not used [clang]
Following condition can be true if minix file system is corrupt, and versio
number is found to be greater than 3. It is fair to say described scenario
is unlikely.
libblkid/src/superblocks/minix.c:107:13: warning: variable 'zone_size' is
used uninitialized whenever
'if' condition is false [-Wsometimes-uninitialized]
} else if (version == 3) {
^~~~~~~~~~~~
libblkid/src/superblocks/minix.c:121:6: note: uninitialized use occurs here
if (zone_size != 0 || ninodes == 0 || ninodes == UINT32_MAX)
^~~~~~~~~
login: prevent OOB read on illegal /etc/hushlogins
If the file /etc/hushlogins exists and a line starts with '\0', the
login tools are prone to an off-by-one read.
I see no reliability issue with this, as it would clearly need a
hostile action from a system administrator. But for the sake of
correctness, I've sent this patch nonetheless.
The SEND_UEVENT=yes|no line is not properly parsed, because the offset
jumps one byte too far behind the equal sign. Therefore, every
configuration that contains the line "SEND_UEVENT=yes" still does not
send an uevent.
The fix is simple: adjust the offset to be "12" instead of "13".
* hwclock.c: replace interpret_date_string() with parse_date().
Eliminates shell injection vulnerability from popen() date(1).
Removes system dependency on date(1).
Reduction in hwclock execution time.
Significant cleanup of hwclock.c code.
* Bug fix for "hwclock --predict --date 'bad_date'" printing:
hwclock: No usable set-to time. Cannot set clock.
The message now matches date(1) for an invalid --date argument.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
Karel Zak [Sat, 4 Mar 2017 16:01:56 +0000 (11:01 -0500)]
build-sys: add parse-date.y
* add lib/parse-date.y to build system
* add necessary autotools stuff to generate .c on the fly
(autotools are smart enough to add generated file to tarball)
* check for bison version by ./autogen.sh
* add non-wanted junk to .gitignore
With some modification by J William Piggott with regard to
moving the parse-date API into timeutils.h
Signed-off-by: J William Piggott <elseifthen@gmx.com>
* lib/parse-date.y - new file
Lib function that parses a date string into a timespec struct.
Derived from gnulib-dd7a871 parse-datetime.y with these changes:
* reduced to a single function API renamed to parse_date()
* removed gnulib dependencies
* removed debugging
* converted to util-linux coding style
* include/cctype.h - new file
Like ctype.h only hard coded to the 'C' locale.
Used by lib/parse-date.y.
Derived from gnulib-dd7a871 c-ctype.h with these changes:
* removed gnulib dependencies
* converted to util-linux coding style
* add requisite util-linux constants
Signed-off-by: J William Piggott <elseifthen@gmx.com>
Karel Zak [Fri, 3 Mar 2017 09:37:37 +0000 (10:37 +0100)]
libsmartcols: allow to add column to already used table
Now it's impossible to add new column if the table already contains
lines with data. This patch forces library to realloc cell array in
the lines to accept a new column.
Damien Le Moal [Fri, 24 Feb 2017 06:45:31 +0000 (15:45 +0900)]
blkzone: Add --count option
The length option is used to specify the number of zones to
operate on. To be more consistent with other tools, have this
option use a number of sectors and introduce the --count option
to allow users to specify a number of zones.
The --count and --length options cannot be used together on
the command line.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Damien Le Moal [Fri, 24 Feb 2017 03:47:29 +0000 (12:47 +0900)]
blkzone: Improve zone information print
Add "0x" to the zone start, length and write pointer print
to make it always clear that the values are Hexadecimal.
Also update the zone condition string and associated comments
to match more closely the wording in the standard document.
The man page is also updated to match the new wording.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Damien Le Moal [Fri, 24 Feb 2017 03:36:08 +0000 (12:36 +0900)]
blkzone: Report all zones if length is not specified
Report all zones of the block device when length is not specified
on the command line. To do this, introduce an inner loop in
blkzone_report to repeatedly issue report zone ioctl to the
device.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
* add UL_ENABLE_ALIAS(NAME, MASTERNAME) to initialize $enable_<name>
according to MASTERNAME. Note that we have to use $build_<mastername>,
the $enable_<mastername> is just AC_ARG_ENABLE() stuff only. The
$build_ is evaluated and modified by our UL_...() functions.
* add enable-schedutils.conf to have build-system regression test for
this use-case
Addresses: https://github.com/karelzak/util-linux/issues/415 Signed-off-by: Karel Zak <kzak@redhat.com>