skullchap / chadstr Goto Github PK
View Code? Open in Web Editor NEWChad Strings - The Chad way to handle strings in C.
License: GNU General Public License v3.0
Chad Strings - The Chad way to handle strings in C.
License: GNU General Public License v3.0
All identifiers starting with two underscores are reserved, see https://port70.net/~nsz/c/c11/n1570.html#7.1.3
main.c
#include "chadstr.h"
int main() {
chadstr test = str("orange apple");
return 0;
}
The result when I try to compile it:
D:\workspace\chadstr>cl /I. main.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29915 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
main.c
D:\workspace\chadstr\chadstr.h(69): fatal error C1112: compiler limit: '129' too many macro arguments, only '127' allowed
Lots of vulns, please consider creating a Rust version.
I know even if this is a kind-of meme, it's a severe limitation for my personal use.
I guess compilers ain't that smart after all....
Now I am back at the dumb strdup
stuff I've been struggling with :(
take example code generate random strings and compile with sanitizers.
$ gcc -fsanitize=address main.c
# ./a.out
=================================================================
==567==ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address 0x7ffe55e4a198 at pc 0x55b34322c058 bp 0x7ffe55e4a0e0 sp 0x7ffe55e4a0d8
WRITE of size 1 at 0x7ffe55e4a198 thread T0
#0 0x55b34322c057 in random_string (/root/chadstr/a.out+0x4057)
#1 0x55b34322c1f6 in main (/root/chadstr/a.out+0x41f6)
#2 0x7f2811d11d09 in __libc_start_main ../csu/libc-start.c:308
#3 0x55b34322a249 in _start (/root/chadstr/a.out+0x2249)
Address 0x7ffe55e4a198 is located in stack of thread T0
SUMMARY: AddressSanitizer: dynamic-stack-buffer-overflow (/root/chadstr/a.out+0x4057) in random_string
Shadow bytes around the buggy address:
0x10004abc13e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10004abc13f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10004abc1400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10004abc1410: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10004abc1420: ca ca ca ca 00 00 00 00 00 00 00 00 00 00 00 00
=>0x10004abc1430: 00 00 00[cb]cb cb cb cb 00 00 00 00 00 00 00 00
0x10004abc1440: 00 00 00 00 00 00 f1 f1 f1 f1 00 f2 f2 f2 00 00
0x10004abc1450: f3 f3 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
0x10004abc1460: 00 f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00
0x10004abc1470: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10004abc1480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
Shadow gap: cc
==567==ABORTING
$
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.