public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* glibc strerrorname_np
@ 2021-11-04 20:23 Jonny Grant
  2021-11-04 20:46 ` Adhemerval Zanella
  2021-11-08  8:36 ` Florian Weimer
  0 siblings, 2 replies; 23+ messages in thread
From: Jonny Grant @ 2021-11-04 20:23 UTC (permalink / raw)
  To: GNU C Library

Hi Carlos
I was pleased to see you added strerrorname_np()

May I ask, I couldn't find the file your implementation is in - could you point it out to me in the glibc repository please?

I noticed on the man page it may return NULL, which is a shame, as then it means we always need to check that before using in every printf etc :-

printf("err %s\n", strerrorname_np(myerr)?strerrorname_np(myerr), "Unknown err");
 
I'd done my own version a while ago as strerrno_s(), and assumed I could never get it accepted anywhere like glibc.
Probably I should have tried to submit it to glibc!
https://github.com/jonnygrant/safec/blob/master/strerrno.c

Would something like my implementation ever be accepted?
errno_t strerrno_s(char * const buf, const rsize_t buflen, const errno_t errnum)


Last quick question, do you know why strerror_r() is considered safer than strerror()? I guess someone could trash the memory returned by it?

char * errstr = strerror(EINVAL);
errstr[0] = '\0';  // trashed the process copy of the string. (or even SEGV it, if it was in some static section of the ELF?)

Kind regards
Jonny

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2021-11-10  1:37 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04 20:23 glibc strerrorname_np Jonny Grant
2021-11-04 20:46 ` Adhemerval Zanella
2021-11-04 22:52   ` Jonny Grant
2021-11-04 23:28     ` Adhemerval Zanella
2021-11-05 11:51       ` Jonny Grant
2021-11-05 13:01         ` Adhemerval Zanella
2021-11-05 22:23           ` Jonny Grant
2021-11-06 12:51             ` Adhemerval Zanella
2021-11-07 17:37               ` Zack Weinberg
2021-11-08 13:56                 ` Adhemerval Zanella
2021-11-08 18:42                   ` Zack Weinberg
2021-11-08 18:52                     ` Adhemerval Zanella
2021-11-08 19:56                       ` Florian Weimer
2021-11-08 20:28                         ` Adhemerval Zanella
2021-11-08 22:22               ` Jonny Grant
2021-11-09 12:30                 ` Adhemerval Zanella
2021-11-09 23:01                   ` Jonny Grant
2021-11-10  1:37                     ` Adhemerval Zanella
2021-11-08  8:36 ` Florian Weimer
2021-11-08 13:36   ` Jonny Grant
2021-11-08 13:42     ` Florian Weimer
2021-11-08 22:14       ` Jonny Grant
2021-11-08 14:01   ` Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).