Commit Graph

19 Commits

Author SHA1 Message Date
Hiltjo Posthuma
a9bedca038 fix some signed/unsigned warnings and style fixes 2015-03-27 22:48:05 +01:00
FRIGN
5af4cdcd60 Audit unexpand(1)
I checked the algorithm already a while ago. What was left was a
couple of style-fixes.
2015-03-17 23:45:03 +01:00
FRIGN
3b825735d8 Implement reallocarray()
Stateless and I stumbled upon this issue while discussing the
semantics of read, accepting a size_t but only being able to return
ssize_t, effectively lacking the ability to report successful
reads > SSIZE_MAX.
The discussion went along and we came to the topic of input-based
memory allocations. Basically, it was possible for the argument
to a memory-allocation-function to overflow, leading to a segfault
later.
The OpenBSD-guys came up with the ingenious reallocarray-function,
and I implemented it as ereallocarray, which automatically returns
on error.
Read more about it here[0].

A simple testcase is this (courtesy to stateless):
$ sbase-strings -n (2^(32|64) / 4)

This will segfault before this patch and properly return an OOM-
situation afterwards (thanks to the overflow-check in reallocarray).

[0]: http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man3/calloc.3
2015-03-10 21:23:36 +01:00
Hiltjo Posthuma
5a6715c0cf unexpand: spaces to tabs 2015-02-20 13:29:38 +01:00
sin
9effb224c8 expand, unexpand: Minor style fix as per the suckless guide 2015-02-17 12:14:44 +00:00
FRIGN
31572c8b0e Clean up #includes 2015-02-14 21:12:23 +01:00
FRIGN
7c578bf5b0 Scrap writerune(), introducing fputrune()
Interface and function as proposed by cls.
Code is also shorter, everything else analogous to fgetrune().
2015-02-11 20:58:00 +01:00
FRIGN
a5ae899a48 Scrap readrune(), introducing fgetrune()
Interface as proposed by cls, but internally rewritten after a few
considerations.
The code is much shorter and to the point, aligning itself with other
standard functions. It should also be much faster, which is not bad.
2015-02-11 20:16:49 +01:00
FRIGN
1b4ba2b303 Remove wchar.h from unexpand(1)
not needed any more.
2015-02-09 00:20:02 +01:00
sin
6397952ab3 Nuke bogus newline 2015-02-08 20:28:18 +00:00
FRIGN
1513c2b766 Refactor unexpand(1) code and manpage, adding tablist support
as already seen for expand(1), only twice as complicated.
2015-02-08 21:24:22 +01:00
FRIGN
fd562481f3 Convert estrto{l, ul} to estrtonum
Enough with this insanity!
2015-01-30 16:52:44 +01:00
Hiltjo Posthuma
3d8d796a95 unexpand: fix eprintf 2014-12-22 10:34:29 +00:00
sin
cd35347203 Convert unexpand(1) to libutf 2014-11-21 17:52:22 +00:00
sin
af8e38f5fa Fix some error messages
There's many more to go.
2014-11-17 16:22:01 +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
Tuukka Kataja
8b87d0098a Add unexpand(1) 2014-06-09 17:00:13 +01:00