Commit Graph

19 Commits

Author SHA1 Message Date
FRIGN
a531865fe5 Audit readlink(1)
1) Properly document e, f and m-flags in the manpage.
2) Clear up the code for the m-flag-handling. Add idiomatic
   '/'-path-traversal as already seen in mkdir(1).
3) Unwrap the SWAP_BUF()-macro.
4) BUGFIX: Actually handle the f-flag properly. Only resolve
   the dirname and append the basename later.
5) Use fputs() instead of printf("%s", ...).
2015-03-20 22:14:31 +01:00
FRIGN
93fd817536 Add estrlcat() and estrlcpy()
It has become a common idiom in sbase to check strlcat() and strlcpy()
using

if (strl{cat, cpy}(dst, src, siz) >= siz)
        eprintf("path too long\n");

However, this was not carried out consistently and to this very day,
some tools employed unchecked calls to these functions, effectively
allowing silent truncations to happen, which in turn may lead to
security issues.
To finally put an end to this, the e*-functions detect truncation
automatically and the caller can lean back and enjoy coding without
trouble. :)
2015-03-17 11:24:49 +01:00
Hiltjo Posthuma
8f436abde6 style: document intentional fallthrough 2015-03-09 00:33:13 +01:00
Hiltjo Posthuma
6c7ff5fda5 code-style: unindent one level of switch 2015-02-20 13:29:38 +01:00
FRIGN
31572c8b0e Clean up #includes 2015-02-14 21:12:23 +01:00
sin
6d4a7989cd readlink: Use eprintf() to report errors 2015-02-11 11:58:13 +00:00
sin
3f3e15b314 readlink: Use strlcat() instead of strncat() 2015-02-11 11:51:57 +00:00
Tai Chi Minh Ralph Eastwood
28e26bc688 readlink: add -m and -f flags 2015-02-11 10:56:58 +00:00
FRIGN
7faf732d0b Edit readlink.1 and document missing flags 2015-02-01 00:43:43 +01:00
sin
88a6d6f97e State the reason for failure in readlink(1) 2014-12-04 12:14:59 +00:00
FRIGN
7fc5856e64 Tweak NULL-pointer checks
Use !p and p when comparing pointers as opposed to explicit
checks against NULL.  This is generally easier to read.
2014-11-14 10:54:30 +00:00
FRIGN
ec8246bbc6 Un-boolify sbase
It actually makes the binaries smaller, the code easier to read
(gems like "val == true", "val == false" are gone) and actually
predictable in the sense of that we actually know what we're
working with (one bitwise operator was quite adventurous and
should now be fixed).

This is also more consistent with the other suckless projects
around which don't use boolean types.
2014-11-14 10:54:20 +00:00
FRIGN
eee98ed3a4 Fix coding style
It was about damn time. Consistency is very important in such a
big codebase.
2014-11-13 18:08:43 +00:00
sin
0c5b7b9155 Stop using EXIT_{SUCCESS,FAILURE} 2014-10-02 23:46:59 +01:00
sin
b5a511dacf Exit with EXIT_SUCCESS/EXIT_FAILURE instead of 0 and 1
Fixed for consistency purposes.
2013-10-07 16:44:22 +01:00
sin
83c2c3d1f5 Add 'not implemented' errors for unimplemented flags
These used to live in TODO but we got rid off them.  Make sure
we keep track of what we want to support by printing a message
when those flags are unimplemented.
2013-10-05 13:51:45 +01:00
David Galos
7adf4f380a Fixing zero-bye append in readlink. Thanks, Willem van de Krol 2013-07-09 19:40:28 -04:00
stateless
7216a53a7e Remove unnecessary exit(1) in usage()
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2013-06-19 19:58:19 +02:00
stateless
f66b47bc6f Add readlink
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2013-06-16 07:46:01 +02:00