summaryrefslogtreecommitdiff
path: root/lib/libutil
AgeCommit message (Collapse)Author
2021-08-01fix typos in word "otherwise".andvar
2021-05-16PR bin/56042kre
Fix typos (2nd acst should have been acdt), 0550 for ist should be 0530 (5.5 hours is not 5 hours and 50 minutes...). Comment out the zp4 zp5 and zp6 zone names. They are supposedly supported by the source (they're in the table) but cannot work, as the parsedate lexer doesn't allow a "word" to start with an alpha and also contain digits. Maybe (just maybe) that could be fixed sometime, but since these have never worked, and no-one has ever seemed to miss them, and they're the only words which are of that form, for now, just stop pretending they work.
2021-03-21note that ttyaction.[35] first appeared in netbsd 1.3.mrg
2020-10-30PR lib/46542kre
Add checks to detect overflow, and also detect other invalid (out of range) inputs for parsedate(). There could be more, and some of what is being added is not perfect, but many calculation overflows will be detected now (and cause an error return) and some of the most bizarre inputs that were previously accepted no longer will be.
2020-10-19Check the year field of a tentative ISO-8601 date format for overflowkre
before committing to it being an 8601 format date, rather than after (or the fall back grammar parser doesn't start with a clean slate). This isn't likely to ever bother anyone, the chances of encountering something that looks just like an 8601 format date, but with a year field so large it overflows a long are kind of slim. If it did happen the chances that the string could be correctly parsed (into something different) by the grammar are even slimmer. But better to do it properly.
2020-10-19Catch the parsedate man page up with recent updates, ans also includekre
some general improvements I've had kicking around for a long time, but never got around to committing.
2020-10-19For touch -d (which uses parsedate()) POSIX specifies that thekre
ISO-8601 format yyyy-mm-ddTHH:MM:SS[radix_and+frac][Z] be accepted. We didn't handle that, as in parsedate(), 'T' represents the military timezone designator, not a padding separator between date & time as POSIX specified it. The way parsedate() is written, fixing this in the grammar/lexer would be hard without deleting support for T as a zone indicator (it is *my* timezone!). So, instead of doing that, parse an ISO-8901 string which occurs right at the start of the input (not even any preceding white space) by hand, before invoking the grammar, and so not involving the lexer. This is sufficient to make touch -d conform. After doing that, we still need to allow earlier valid inputs, where an ISO-8601 format (using space as the separator, but without the 'Z' (Zulu, or UTC) suffix) followed by an arbitrary timezone designation, and other modifiers (eg: "+5 minutes" work. So we call the grammar on whatever is left of the input after the 8601 string has been consumed. This all "just works" with one exception, a format like "yyyy-mm-dd hh:mm:ss +0700" would have the grammar parse just "+0700" which by itself would be meaningless, and so wasn't handled. Add a grammar rule & processing to Handle it. Also note that while POSIX specifies "at least 4" digits in the YYYY field, we implement "at least one" so years from 0-999 continue to be parsed as they always have (nb: these were, and continue to be, treated as absolute year numbers, year 10 is year 10, not 2010). Years > 2 billion (give or take) cannot be represented in the tm_year field of a struct tm, so there's a limit on the max number of digits as well.
2020-10-19POSIX requires that when converting 2 digit year representations tokre
actual specific years, values from 69-99 be treated as 20th century, and values from 0-68 be treated as 21st century. This allows for those unfortunate enough to reside in a timezone west of Greenwich to convert the epoch (or a time very close to it) to text, write that with just two digits, and correctly convert it back to a time near the epoch, rather than to something in 2069. We used to split things so 0-69 were 21st century, and 70-99 were 20th. Change that (this requires a change in the parsedate ATF tests which test this specific boundary). While here, add support for another POSIX requirement, that the radix char before fractional seconds can be either a ',' or a '.'. We used to allow only '.', add support for ','. This is something of a meaningless change, as parsedate() returns a time_t in which there is no way to represent fractional seconds, so there's little point in ever specifying them regardless of what char is used for the "decimal point" - they will be ignored anyway. But at least fractional seconds using a ',' as the radix char will no longer cause the conversion to fail (or do something else bizarre).
2020-07-30Fix grammar.uwe
2020-03-30fail to create a pidfile if hostname contains '/'ryo
2019-12-27s/sucess/success/ in comment.msaitoh
2019-12-07Remove trailing whitespace.wiz
2019-12-06Correct the man page, and say that the printf(3) format characters needchristos
to be uintmax_t.
2019-10-13introduce some common variables for use in GCC warning disables:mrg
GCC_NO_FORMAT_TRUNCATION -Wno-format-truncation (GCC 7/8) GCC_NO_STRINGOP_TRUNCATION -Wno-stringop-truncation (GCC 8) GCC_NO_STRINGOP_OVERFLOW -Wno-stringop-overflow (GCC 8) GCC_NO_CAST_FUNCTION_TYPE -Wno-cast-function-type (GCC 8) use these to turn off warnings for most GCC-8 complaints. many of these are false positives, most of the real bugs are already commited, or are yet to come. we plan to introduce versions of (some?) of these that use the "-Wno-error=" form, which still displays the warnings but does not make it an error, and all of the above will be re-considered as either being "fix me" (warning still displayed) or "warning is wrong."
2019-10-08-Wstringop-truncation is only gcc.christos
2019-10-04Ignore strncpy(foo, bar, sizeof(foo)) for the wtmp fields where we don'tchristos
want NUL termination. We can't use pragma's because the old gcc complains about the new warnings it does not understand.
2019-10-03annotate __deadtnn
2019-10-03provide a default error function instead of trying to cast exit(3).christos
2019-08-22Teach getdiskrawname and getdiskcookedname about zvols.brad
Reviewed by Christos
2019-04-29snprintb(3) says that, in the new(?) Torek format, all fields specs end with \0kre
The F spec is one of those, it should be terminated with \0 just like all the others (irrelevant that it has no extra data to delimit). Fix <sys/mman.h> to define the snprintb() format string correctly (include the missing \0's). Fix the copy of that definition included into snprintb(3) to match the updated mman.h version (ride the date bump from the day before yesterday .. this is the same change, just corrected). Undo the previous snprintb.c change ("off by one" fix) which was an attempt to make the broken mman.h usage work (and did, but not the way it should be done). Also, after using the new * format (instead of only when something has already matched) skip the associated data so we don't attempt to interpret it as more field specifiers. This func needs lots of TLC! Fix the ATF tests for snprintb() to not assume that F format is really exactly like f format, and has data after the field specifier. It doesn't. Add several more tests (including testing the '*' field operator recently added).
2019-04-27Remove trailing whitespace.wiz
2019-04-27remove dup linechristos
2019-04-27Document the '*' field and give a more complex example with F and *.christos
2019-03-08s/ the the / the /msaitoh
2018-12-28Document "ROOT." syntax before documenting a generic .alnsn
2018-12-27No need to quadruple a buffer because strunvis(3) doesn't expand.alnsn
2018-10-06use the right type.christos
2018-10-06If fs_spec starts with the special string "ROOT.", replace it with a devicejmcneill
path derived from the value of the kern.root_device sysctl.
2018-06-24Fix stack use after scope in libutil/ptykamil
The pt variable's elements are used after the end of the pt scope. A move of pt to outer scope fixes this. Detected with MKSANITIZER/ASan with tmux(1), a forkpty(3) user.
2018-06-24Prevent underflow buffer read in trim_whitespace() in libutil/passwd.ckamil
If a string is empty or contains only white characters, the algorithm of removal of white characters at the end of the passed string will read buffer at index -1 and keep iterating backward. Detected with MKSANITIZER/ASan when executing passwd(1).
2018-04-05Use mdoc macros.wiz
2018-04-04Document opendisk1() - it has been around long enough.kre
(pity about the name...) XXX pullup-8
2017-10-23Sort errors.wiz
2017-10-22Add snprintb_m to the NAME section.abhinav
2017-10-22Add missing functions to the NAME sectionabhinav
2017-07-03Remove workaround for ancient HTML generation code.wiz
2017-06-14Stop including <sys/user.h> in userland librarieskamil
This header in this context is freebsdism.
2017-04-01Add man page links for:abhinav
EV_SET to kqueue(2) getmntoptstr, getmntoptnum, freemntopts to getmntopts(3) Reviewed by wiz@
2017-03-30Use Sy to highlight the table header.abhinav
2017-03-30Add missing functionsabhinav
2017-03-30Add getmntoptstr, getmntoptnum, and freemntopts to the NAME sectionabhinav
Fix couple of sentences getmntoptstr, getmntoptnum, and freemntopts need to be linked to the getmntopts(3) man page as well. Will do in a later commit after doing a relase build test.
2017-03-30Add getdiskcookedname to the NAME sectionabhinav
Fix couple of typos.
2017-03-22parsedate.y: meaningless KNF of a comment (no code changes)kre
parsedate.3: add an item in BUGS noting the weirdness of "next" The real purpose of this commit is to supply the following message which should be used for the immediately previous commit, replacing its commit message (the two are similar, but definitely not the same). With thanks to gdt@ for pointing out one of the (many) errors in the previous message (and noting others I had already seen). ---- Make parsedate handle "12 noon" and "12 midnight" (including when the time given is "12:00" or "12:00:00") - but only for exactly 12 o'clock. "12:00:01" is am or pm, not noon or midnight. "12 am" remains as an alias for "12 midnight", and "12 pm" for noon, though both are strictly (pedanticly) invalid (and meaningless.) Note that "12 midnight" (or "12 am") means 00:00:00 (ie: midnight at the start of the day, not at the end.)
2017-03-22Make parsedate handle "12 noon" and "12 midnight" (including whenkre
the time is "12:00" or "12:00:00) - but only for exactly 12 o'clock. "12:00:01" is am or pm, not noon or midnight. "12 am" remains as an alias for "12 midnight", and "12 pm" for midnight, though both are strictly invalid (and meaningless.) Note that "12 pm" means 00:00:00 (ie: midnight at the start of the day, not at the end.)
2017-03-22Fix PR lib/52101 -- 12:30 am is 00:30:00 and 12:30 pm is 12:30:00kre
2017-01-29new lookup order will be in 7.1 before 8.0snj
2016-12-29Make this portable to other OSschristos
2016-12-23Complete a sentenceabhinav
and replace full stop with a comma at one place as the sentence wasn't finished
2016-06-26Remove dawn/sunup/sunset/sundown (sunrise was never there...)kre
If 06:00 or 18:00 are wanted, just say "06:00" (etc). If these are ever added back, they really should determine location, and calculate actual sunrise/sunset times for the location and date. That's not likely to happen...
2016-06-07Fix typo. Sort errors.wiz