Re: bugs in strlen, strstr setlocale -- i386
Laurent Bercot <[email protected]>
| Newsgroups | gmane.linux.lib.dietlibc |
|---|---|
| Message-ID | <[email protected]> |
> Seems that strlen works bad with diet -Os. At least on i386 > with my compiler. What should strlen(NULL) return? > > POSIX says nothing, true? POSIX says nothing indeed. It is assumed that the argument to strlen will be a non-null pointer. Segfaulting on strlen(NULL) is highly desirable. strlen(NULL) is a programming error and needs to be reported as loudly and obnoxiously as possible; libraries, and especially the libc, should NOT do any defensive programming. A fix is indeed needed... on architectures where strlen(NULL) returns something valid. strlen(NULL) should crash on every architecture. -- Laurent