summaryrefslogtreecommitdiffstats
path: root/lib/libc
Commit message (Collapse)AuthorAgeFilesLines
...
* | locales: Fix eucJP sorting (broken upstream?)bapt2015-11-011-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Sorting eucJP text with "sort" resulted in an illegal sequence while "gsort" worked. This was traced back to mbrtowc handling which was broken for eucJP (probably eucCN, eucKR, and eucTW as well). This small fix took hours to figure out. The OR operation to build the wide character requires an unsigned character to work correctly. The euc wcrtowc conversion is probably broken upstream in Illumos as well. Triggered by: misc/freebsd-doc-ja in ports (encoded in eucJP) Submitted by: marino Obtained from: DragonflyBSD
* | libc: Fix (and improve) nl_langinfo (CODESET)bapt2015-11-012-9/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The output of "locale charmap" is identical to the result of nl_langinfo (CODESET) for any given locale. The logic for returning the codeset was very simplistic. It just returned portion of the locale name after the period (e.g. en_FR.ISO8859-1 returned "ISO8859-1"). When softlinks were added to locales, this broke. e.g.: en_US returned "" en_FR.UTF8 returned "UTF8" en_FR.UTF-8 returned "UTF-8" zh_Hant_HK.Big5HKSCS returned "Big5HKSCS" zh_Hant_TW.Big5 returned "Big5" es_ES@euro returned "" In order to fix this properly, the named locale cannot be used to determine the encoding. This information was almost available in the rune data. Unfortunately, all the single byte encodings were listed as "NONE" encoding. So I adjusted localedef tool to provide more information about the encoding. For example, instead of "NONE", the LC_CTYPE used by fr_FR.ISO8859-15 is now encoded as "NONE:ISO8859-15". The locale handlers now check if the first four characters of the encoding is "NONE" and if so, treats it as a single-byte encoding. The nl_langinfo handling of CODESET was adjusting accordingly. Now the following is returned: en_US returns "ISO8859-1" fr_FR.UTF8 returns "UTF-8" fr_FR.UTF-8 returns "UTF-8" zh_Hant_HK.Big5HKSCS returns "Big5" zh_Hant_TW.Big5 returns "Big5" es_ES@euro returns "ISO8859-15" as before, "C" and "POSIX" locales return "US-ASCII". This is a big improvement. The result of nl_langinfo can never be a zero-length string and it will always exclusively one of the values of the character maps of /usr/src/tools/tools/locale/etc/final-maps. Submitted by: marino Obtained from: DragonflyBSD
* | collate: Fix expansion substitions (broken upstream too)bapt2015-10-232-57/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Through testing, the user noted that some Cyrillic characters were not sorting correctly, and this was confirmed. After extensive testing and review, the localedef tool was eliminated as the culprit. The sustitutions were encoded correctly in LC_COLLATE. The error was mainly in wcscoll where character expansions were mishandled. The main directive pass routines had to be written to go back for a new collation value when the "state" variable was set. Before pointers were being advanced, the second lookup was gettting applied to the wrong character, etc. The "eat expansion codes" section on collate.c also had a bug. Later own, the "state" variable logic was changed to only set if next code was greater than zero (rather than >= 0). Some additional cleanups got captured from previous work: 1) The previous commit moved the binary search comment from the correct location to a wrong location because it's wrong upstream in Illumos. The comment has little value so I just removed it. 2) Don't check if pointers are null before freeing, this is redundant as free() handles null pointers. 3) The two binary search trees were standardized wrt initialization 4) On the binary search trees, a negative "high" exits rather than checking the table count again. Submitted by: marino Obtained from: DragonflyBSD
* | libc/collate: minor tweaks / fixbapt2015-10-221-27/+30
| | | | | | | | | | | | | | | | | | | | The main "fix" here is properly setting a collate loading error for each early return. Tweaks include removing unnecessary null checks, adding assertions (from Illumos) and a couple of variables to reduces code differences and improve readability. For normal use, there are no functional changes here. Obtained from: DragonflyBSD, Illumos
* | Merge from headbapt2015-10-193-4/+54
|\ \ | |/
| * Document bitset(9)cem2015-10-171-2/+3
| |
| * resolver: automatically reload /etc/resolv.confvangyzen2015-10-142-2/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On each resolver query, use stat(2) to see if the modification time of /etc/resolv.conf has changed. If so, reload the file and reinitialize the resolver library. However, only call stat(2) if at least two seconds have passed since the last call to stat(2), since calling it on every query could kill performance. This new behavior is enabled by default. Add a "reload-period" option to disable it or change the period of the test. Document this behavior and option in resolv.conf(5). Polish the man page just enough to appease igor. https://lists.freebsd.org/pipermail/freebsd-arch/2015-October/017342.html Reviewed by: kp, wblock Discussed with: jilles, imp, alfred MFC after: 1 month Relnotes: yes Sponsored by: Dell Inc. Differential Revision: https://reviews.freebsd.org/D3867
* | Include sys/*.h earlierbapt2015-10-141-3/+5
| | | | | | | | Reported by: kib
* | Commit log from Dragonfly:bapt2015-10-134-17/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | FreeBSD extended ctypes to include numbers (e.g. isnumber()) but never actually implemented it. The isnumber() function was equivalent to the isdigit() function in every case. Now that DragonFly's ctype source files have number definitions, the number ctype can finally be implemented. It's given a new flag _CTYPE_N. The isalnum() and iswalnum() functions have been changed to use this flag rather than the _CTYPE_D digit flag. While isalnum(), isnumber(), and their wide equivalents now return different values in locale cases, the ishexnumber() and iswhexnumber() functions are unchanged. They are still aliases for isxdigit() and iswxdigit(). Also change ctype.h for isdigit and isxdigit to use sbistype like the other functions. Obtained from: dragonfly
* | Merge from headbapt2015-10-13281-2054/+1555
|\ \ | |/
| * Refactor the test/ Makefiles after recent changes to bsd.test.mk (r289158) andngie2015-10-1226-60/+9
| | | | | | | | | | | | | | | | | | | | | | | | netbsd-tests.test.mk (r289151) - Eliminate explicit OBJTOP/SRCTOP setting - Convert all ad hoc NetBSD test integration over to netbsd-tests.test.mk - Remove unnecessary TESTSDIR setting - Use SRCTOP where possible for clarity MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Divison
| * Change the default setting of kern.ipc.shm_allow_removed from 0 to 1.trasz2015-10-101-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes the need for manually changing this flag for Google Chrome users. It also improves compatibility with Linux applications running under Linuxulator compatibility layer, and possibly also helps in porting software from Linux. Generally speaking, the flag allows applications to create the shared memory segment, attach it, remove it, and then continue to use it and to reattach it later. This means that the kernel will automatically "clean up" after the application exits. It could be argued that it's against POSIX. However, SUSv3 says this about IPC_RMID: "Remove the shared memory identifier specified by shmid from the system and destroy the shared memory segment and shmid_ds data structure associated with it." From my reading, we break it in any case by deferring removal of the segment until it's detached; we won't break it any more by also deferring removal of the identifier. This is the behaviour exhibited by Linux since... probably always, and also by OpenBSD since the following commit: revision 1.54 date: 2011/10/27 07:56:28; author: robert; state: Exp; lines: +3 -8; Allow segments to be used even after they were marked for deletion with the IPC_RMID flag. This is permitted as an extension beyond the standards and this is similar to what other operating systems like linux do. MFC after: 1 month Relnotes: yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3603
| * Use proper function prototypes.rodrigc2015-10-072-4/+4
| | | | | | | | Eliminates -Wstrict-prototypes warning
| * Document the recently added pl_syscall_* fields in struct ptrace_lwpinfo.jhb2015-10-071-1/+24
| | | | | | | | | | Reviewed by: emaste, kib Differential Revision: https://reviews.freebsd.org/D3833
| * truss: Add support for utrace(2).bdrewery2015-10-061-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This uses the kdump(1) utrace support code directly until a common library is created. This allows malloc(3) tracing with MALLOC_CONF=utrace:true and rtld tracing with LD_UTRACE=1. Unknown utrace(2) data is just printed as hex. PR: 43819 [inspired by] Reviewed by: jhb MFC after: 2 weeks Relnotes: yes Differential Revision: https://reviews.freebsd.org/D3819
| * - address grammarjgh2015-10-051-7/+6
| | | | | | | | | | | | | | | | PR: 203440 (based on) Submitted by: ceratv@rpi.edu Approved by: wblock@ (mentor) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D3813
| * Revert r288628 and instead fix a discrepancy between the posix_fadvise(2)markj2015-10-031-5/+7
| | | | | | | | | | | | | | man page and POSIX: posix_fadvise(2) returns an error number on failure. Reported by: jilles MFC after: 1 week
| * - Move PF_LOCAL at the end of the array. PF_INET{,6} is used more often.hrs2015-10-031-7/+9
| | | | | | | | | | | | | | - Add SOCKTYPE_ANY to PF_LOCAL. - Apply AI_CANONNAME to only AF_INET{,6}. It is not meaningful for the other AFs.
| * wordexp: Rewrite to make WRDE_NOCMD reliable.jilles2015-09-302-94/+148
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Shell syntax is too complicated to detect command substitution and unquoted operators reliably without implementing much of sh's parser. Therefore, have sh do this detection. While changing sh's support anyway, also read input from a pipe instead of arguments to avoid {ARG_MAX} limits and improve privacy, and output count and length using 16 instead of 8 digits. The basic concept is: execl("/bin/sh", "sh", "-c", "freebsd_wordexp ${1:+\"$1\"} -f "$2", "", flags & WRDE_NOCMD ? "-p" : "", <pipe with words>); The WRDE_BADCHAR error is still implemented in libc. POSIX requires us to fail strings containing unquoted braces with code WRDE_BADCHAR. Since this is normally not a syntax error in sh, there is still a need for checking code in libc, we_check(). The new we_check() is an optimistic check that all the characters <newline> | & ; < > ( ) { } are quoted. To avoid duplicating too much sh logic, such characters are permitted when quoting characters are seen, even if the quoting characters may themselves be quoted. This code reports all WRDE_BADCHAR errors; bad characters that get past it and are a syntax error in sh return WRDE_SYNTAX. Although many implementations of WRDE_NOCMD erroneously allow some command substitutions (and ours even documented this), there appears to be code that relies on its security (codesearch.debian.net shows quite a few uses). Passing untrusted data to wordexp() still exposes a denial of service possibility and a fairly large attack surface. Reviewed by: wblock (man page only) MFC after: 2 weeks Relnotes: yes Security: fixes command execution with wordexp(untrusted, WRDE_NOCMD)
| * In this context fclose() can never fail, so assert it in the testdelphij2015-09-291-0/+1
| | | | | | | | case.
| * Annotate arm userspace assembler sources stating their tolerance tokib2015-09-2930-1/+56
| | | | | | | | | | | | | | the non-executable stack. Reviewed by: andrew Sponsored by: The FreeBSD Foundation
| * Use calloc() instead of malloc + memset.delphij2015-09-291-2/+1
| | | | | | | | MFC after: 2 weeks
| * fnmatch(): Remove exponential behaviour as in sh r229201.jilles2015-09-271-28/+49
| | | | | | | | | | | | The old code was exponential in the number of asterisks in the pattern. However, once a match has been found upto the next asterisk, the previous asterisks are no longer relevant.
| * Add missing CLEANFILES.bdrewery2015-09-241-0/+2
| | | | | | | | | | MFC after: 1 week Sponsored by: EMC / Isilon Storage Division
| * Use ANSI C prototypes. Eliminates -Wold-style-definition warnings.rodrigc2015-09-231-2/+2
| | | | | | | | | | Submitted by: Sascha Wildner <swildner@dragonflybsd.org> Obtained from: DragonFlyBSD (commit 5d7d35b17f98588c39b30036f1a3fe8802935c2c)
| * Use ANSI C prototypes. Eliminates -Wold-style-definition warnings.rodrigc2015-09-224-21/+9
| |
| * Use ANSI C prototypes. Eliminates -Wold-style-definition warnings.rodrigc2015-09-2235-409/+235
| |
| * Use proper function prototype for readdir().rodrigc2015-09-221-10/+6
| | | | | | | | | | | | | | Eliminates -Wstrict-prototypes warning Submitted by: Joerg Sonnenberger <joerg@dragonflybsd.org> Obtained from: DragonFlyBSD (commit 2a6aec8dab58c89961cabcfdb92e0d0ae256dea4)
| * Use ANSI C prototypes. Eliminates -Wold-style-definition warnings.rodrigc2015-09-221-1/+1
| |
| * Avoid adding duplicates into OBJS. bsd.lib.mk already handles addingbdrewery2015-09-221-2/+0
| | | | | | | | | | | | | | entries to OBJS based on SRCS. MFC after: 1 week Sponsored by: EMC / Isilon Storage Division
| * Use ANSI C prototypes. Eliminates -Wold-style-definition warnings.rodrigc2015-09-201-45/+16
| |
| * Use ANSI C prototypes. Eliminates -Wold-style-definition warnings.rodrigc2015-09-209-49/+20
| |
| * Use ANSI C prototypes. Eliminates -Wold-style-definition warnings.rodrigc2015-09-201-25/+10
| |
| * Use ANSI C prototypes. Eliminates -Wold-style-definition warnings.rodrigc2015-09-201-7/+3
| |
| * Use ANSI C prototypes. Eliminates -Wold-style-definition warnings.rodrigc2015-09-201-3/+1
| |
| * Use ANSI C prototypes. Eliminates -Wold-style-definition warnings.rodrigc2015-09-201-25/+7
| |
| * Use ANSI C prototypes. Eliminates -Wold-style-definition warnings.rodrigc2015-09-206-23/+7
| |
| * Use ANSI C prototypes. Eliminates -Wold-style-definition warnings.rodrigc2015-09-205-106/+52
| |
| * Use ANSI C prototypes. Eliminates -Wold-style-definition warnings.rodrigc2015-09-203-8/+6
| |
| * Remove names from some prototypesrodrigc2015-09-201-1/+1
| |
| * Remove names from some prototypesrodrigc2015-09-201-2/+2
| |
| * Use ANSI C prototypes. Eliminates -Wold-style-definition warnings.rodrigc2015-09-2012-51/+28
| |
| * Use ANSI C prototypes. Eliminates -Wold-style-definition warnings.rodrigc2015-09-2032-142/+56
| |
| * Remove names from some prototypesrodrigc2015-09-2012-14/+14
| |
| * Remove names from some prototypesrodrigc2015-09-202-5/+5
| |
| * Remove names from prototypesrodrigc2015-09-203-7/+7
| |
| * Add include for declaration of _set_tp(). Eliminates -Wmissing-prototypes ↵rodrigc2015-09-207-0/+7
| | | | | | | | warnings.
| * Add declarations to eliminate -Wmissing-prototypes warningsrodrigc2015-09-201-0/+3
| |
| * Use ANSI C prototypes.rodrigc2015-09-201-69/+31
| | | | | | | | Eliminates gcc 4.9 warnings.
| * Add declaration to eliminate -Wmissing-prototypes warningrodrigc2015-09-201-0/+2
| |
OpenPOWER on IntegriCloud