Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>... there is a string struct with this inner char s is super-evil.

Apparently, the author wanted to minimize the size of string object by getting rid of the data pointer. Makes sense in general.

However, with modern gcc this use triggers secure check to prevent memory overwrites/ string overflow.

The check could be disabled/minimized by adding to CFLAGS -Wstringop-overflow=0. Just to prevent it from crashing on this.

Also this design could be salvaged by replacing direct references to string->s (string's data pointer) with an inline call to some func:

  char* c_str(string*)
which would return an offseted pointer to the data off string* base pointer. If this is done, then, probably, the stringop-overflow option could be reverted.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: