mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 16:28:30 +00:00
Implement more security stuff
- Support deterministic stacks on OpenBSD - Support OpenBSD system call origin verification - Fix overrun by one in chibicc string token allocator - Get all chibicc tests passing under Address Sanitizer
This commit is contained in:
parent
cbfd4ccd1e
commit
c843243322
56 changed files with 376 additions and 245 deletions
|
@ -18,16 +18,18 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
|
||||
/**
|
||||
* Mutates string to ASCII uppercase w/ limit.
|
||||
*
|
||||
* @praam s is string
|
||||
* @praam n is max bytes to consider
|
||||
* @return string
|
||||
*/
|
||||
char *strntoupper(char *s, size_t n) {
|
||||
unsigned char *p = (unsigned char *)s;
|
||||
for (;;) {
|
||||
if (n-- && *p) {
|
||||
if ('a' <= *p && *p <= 'z') {
|
||||
*p -= 'a' - 'A';
|
||||
}
|
||||
++p;
|
||||
} else {
|
||||
break;
|
||||
size_t i;
|
||||
for (i = 0; s[i] && i < n; ++i) {
|
||||
if ('a' <= s[i] && s[i] <= 'z') {
|
||||
s[i] -= 'a' - 'A';
|
||||
}
|
||||
}
|
||||
return s;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue