Aniruddhan Murali <[email protected]> wrote:
> Hello everyone!

hello

> I am an aspiring new contributor (github id: ashamedbit) to tinycc

please don't use github, we have plenty of alternatives that suck less

> I was just studying the code and hunting for bugs in tinycc that I wanted to 
> get your opinion on:
> 
> In the function tcc_debug_start in tccdbg.c
> https://github.com/TinyCC/tinycc/blob/fada98b1ce9ee0c36771183177218828ccb9b9de/tccdbg.c#L1135-L1138

for people that dislike "modern web": /tccdbg.c:1135

> If getcwd fails then variable buf is uninitialized.
> Subsequently variable buf is used in other places like lines 1137 and 1204
> The fix should check return value of getcwd before using variable buf.

indeed
if I were to fix that, I'd add the least amount of code possible: if it fails, 
exit with an error message

> In the function pstrcpy, I believe there should be a null check for pointer s.
> https://github.com/TinyCC/tinycc/blob/fada98b1ce9ee0c36771183177218828ccb9b9de/libtcc.c#L147-L166

for people that dislike "modern web": /libtcc.c:149

> The function is called in a lot of places and this can possibly lead to null 
> pointer dereference, especially at this point (when s is null)
> c = *s++;

I'd have done the least again: document that it's the callers responsibility 
for s to be valid - why would you call pstrcpy with a NULL pointer?! it's a 
mistake to fix on the caller's side
and if you wanted to catch bugs with it: tools already exist (asan, valgrind, 
etc), there's no need for this "dead weight" (checking for s =/= null)

tl;dr I'd fix both with very few changes

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to