lib/mbalign: fix unsigned integer overflow [AddressSanitizer]

This error was reported 155 times.

lib/mbsalign.c:322:18: runtime error: unsigned integer overflow: 0 - 1
cannot be represented in type 'size_t' (aka 'unsigned long')

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
cal: fix signed integer overflow [AddressSanitizer]

misc-utils/cal.c:811:16: runtime error: signed integer overflow:
2147483645 + 536870911 cannot be represented in type 'int'

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
lib: fix crc32 and crc64 interger overflows [AddressSanitizer]

lib/crc32.c:111:11: runtime error: unsigned integer overflow: 0 - 1
cannot be represented in type 'size_t' (aka 'unsigned long')

lib/crc64.c:101:12: runtime error: unsigned integer overflow: 0 - 1
cannot be represented in type 'size_t' (aka 'unsigned long')

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
fdisk: (sgi) fix unsigned integer overflow [AddressSanitizer]

include/pt-sgi.h:103:7: runtime error: unsigned integer overflow: 0 -
1186450447 cannot be represented in type 'unsigned int'

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
strutils: fix unsigned integer overflows [AddressSanitizer]

include/strutils.h:174:10: runtime error: unsigned integer overflow: 0 -
1 cannot be represented in type 'size_t' (aka 'unsigned long')

include/strutils.h:178:6: runtime error: unsigned integer overflow:
18446744073709551615 + 1 cannot be represented in type 'size_t' (aka
'unsigned long')

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
lslogins: allow changing password changed and expiration time formats

The password change and expiry has are marked with resolution of a day,
so add a new short iso-8601 format.  With this system admins can easily
find users has not updated their password lately

$ lslogins --time-format=iso --user --output=pwd-change,user | sort -n

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
lslogins: make journald last logs time stamps to honor --time-format

This makes by default the last logs to have year in output when necessary.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
lslogins: tell why command failed

Printing usage() without hint what is wrong does not help an user.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
lslogins: fix short options

Usage is promising -e is an option alias of --export, so make it work.
And get rid of -x that was accepted, but not in use.

Long only enum member OPT_VER was probably a development time idea, that
never got to be used.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
lslogins: reject unknown time format arguments

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
lslogins: add space to systemd journal header and message

This commit changes journal messages in individual user printout the
following way.

Dec 13 16:02:05 systemd[324]:Time has been changed	(old)
Dec 13 16:02:05 systemd[324]: Time has been changed	(new)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
lslogins: use hardcoded paths from pathnames.h

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
chfn: remove function prototypes

Requires resuffling functions order they work without issues.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
chfn: rewrite prompt() to use strutils

The left and right white space trimming can be done with strutils.h
[lr]trim_whitespace() functions.

As a minor fix when user input exceeds maxium allowed gecos field length
the remaining characters in stdin are purged so that re-prompting works
correctly.

Additionally the prompt() is made to add message to check_gecos_string(),
so that there are less similar strings for translation project to deal.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
chfn: use xasprintf() rather than bunch of strlen() and malloc() calls

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
chfn: fix usage() regression

Commit db433bf737a5fd4e1c7cca5e3603934743eebd1c changed -u for --help to
-h, that is not true.  The -h is short hand for --home-phone.  And the
--version is accompanied with -v not -V.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
chfn: simplify parse_passwd() by using strsep()

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
chfn: add minimalistic struct chfn_control

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
chfn: clean up parse_argv()

Use switch() case ?: for all option parsing, as in most of the other
source files.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
chfn: move new and old finger structs to chfn control struct

This change is a little bit messy, and requires a comment the struct
finfo should not have 'struct passwd *pw' as it's member.  The earlier
struct design would have been burden to maintain, and confusing to use.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>