Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

IOT trap -- core dumped


devel / comp.lang.c / "White House to Developers: Using C or C++ Invites Cybersecurity Risks"

SubjectAuthor
* "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Lynn McGuire
+* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Lawrence D'Oliveiro
|`- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
+* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"John McCue
|+* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Kaz Kylheku
||`- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Tim Rentsch
|`* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Lawrence D'Oliveiro
| `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Blue-Maned_Hawk
|  `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Lawrence D'Oliveiro
|   +- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|   `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Blue-Maned_Hawk
|    `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Lawrence D'Oliveiro
|     `- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Blue-Maned_Hawk
+- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Blue-Maned_Hawk
+- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Michael S
+* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"David Brown
|+- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Janis Papanagnou
|+* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Kaz Kylheku
||`* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"David Brown
|| +* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|| |`* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"David Brown
|| | +* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Malcolm McLean
|| | |`- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|| | `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|| |  +- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|| |  `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"David Brown
|| |   `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|| |    `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"David Brown
|| |     `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|| |      `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|| |       `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"David Brown
|| |        `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|| |         `- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|| +- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Lawrence D'Oliveiro
|| `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Janis Papanagnou
||  `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"David Brown
||   `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Janis Papanagnou
||    `- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"David Brown
|+* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Lawrence D'Oliveiro
||`* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|| +* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Lawrence D'Oliveiro
|| |+- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|| |+- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"bart
|| |`* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Malcolm McLean
|| | `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Lawrence D'Oliveiro
|| |  `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Michael S
|| |   `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Lawrence D'Oliveiro
|| |    +* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|| |    |`* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Lawrence D'Oliveiro
|| |    | `- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|| |    `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Michael S
|| |     `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Lawrence D'Oliveiro
|| |      `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Michael S
|| |       +* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"bart
|| |       |+* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Michael S
|| |       ||`* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"David Brown
|| |       || +* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Michael S
|| |       || |`* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"David Brown
|| |       || | +- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Kaz Kylheku
|| |       || | `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Paavo Helde
|| |       || |  +* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"David Brown
|| |       || |  |+* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"bart
|| |       || |  ||`- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"David Brown
|| |       || |  |`- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Ross Finlayson
|| |       || |  `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Lawrence D'Oliveiro
|| |       || |   +* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|| |       || |   |`* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Kaz Kylheku
|| |       || |   | `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|| |       || |   |  `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Kaz Kylheku
|| |       || |   |   `- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|| |       || |   `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"paavo512
|| |       || |    +- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|| |       || |    `- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Scott Lurndal
|| |       || `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Kaz Kylheku
|| |       ||  `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"David Brown
|| |       ||   `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Michael S
|| |       ||    `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"David Brown
|| |       ||     +- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Michael S
|| |       ||     `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Lawrence D'Oliveiro
|| |       ||      `- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"aph
|| |       |`- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Lawrence D'Oliveiro
|| |       +* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"aph
|| |       |`* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Lawrence D'Oliveiro
|| |       | `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|| |       |  `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Kaz Kylheku
|| |       |   `- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|| |       +- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Lawrence D'Oliveiro
|| |       `- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Tim Rentsch
|| `* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Kenny McCormack
||  `- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|`- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
+* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Scott Lurndal
|`* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Lynn McGuire
| +- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Lawrence D'Oliveiro
| `- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Scott Lurndal
+* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Blue-Maned_Hawk
|+- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Chris M. Thomasson
|+* [OT] UTF-8 sig. Was: "White House to Developers: Using C or C++ Invites CyberseBen Bacarisse
||+- Re: [OT] UTF-8 sig. Was: "White House to Developers: Using C or C++ Invites CybScott Lurndal
||`* Re: [OT] UTF-8 sig. Was: "White House to Developers: Using C or C++ Invites CybBlue-Maned_Hawk
|| +* Re: [OT] UTF-8 sig. Was: "White House to Developers: Using C or C++ Invites CybKeith Thompson
|| +* Re: [OT] UTF-8 sig. Was: "White House to Developers: Using C or C++ Invites CybBen
|| `- Re: [OT] UTF-8 sig. Was: "White House to Developers: Using C or C++ Invites Cybyeti
|`- Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Lynn McGuire
+* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"David LaRue
+* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Derek
`* Re: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"Mr. Man-wai Chang

Pages:12345678910
Re: avoiding strdup()

<87r0gizzuo.fsf@nosuchdomain.example.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51953&group=comp.lang.c#51953

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: avoiding strdup()
Date: Sat, 09 Mar 2024 16:37:19 -0800
Organization: None to speak of
Lines: 38
Message-ID: <87r0gizzuo.fsf@nosuchdomain.example.com>
References: <us0brl$246bf$1@dont-email.me>
<pan$4fc39$61bdfbef$3ca9a71a$af842694@invalid.invalid>
<87y1ayj6hs.fsf_-_@bsb.me.uk>
<pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid>
<usc845$10v6e$1@dont-email.me>
<pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid>
<ushea7$28prq$2@dont-email.me> <ushnkb$1rnlb$4@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="18a65937555f48f1385aec071e6a1095";
logging-data="2735058"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ndM3i4o1vSzycPSr5IhHV"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:DKVskR5bdXT5TW+xlN6mUIL19S0=
sha1:Z8HOBfP4UYEOmHZ5ltIuOcRU5fE=
 by: Keith Thompson - Sun, 10 Mar 2024 00:37 UTC

vallor <vallor@cultnix.org> writes:
[...]
> Meanwhile, saw someone in another group write:
>
> char * something;
> something = strdup("writable string etc.");
> if( something == NULL ) { etc. }
>
> But that won't work if --std=c99, does work for g99 and c2x.
> The (Linux) man page says:
> /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200809L
>
> I asked Google about it being a POSIX extension
> added at that late date, and it gave me an answer
> about the C standard:
>
> "C9X London meeting update"
> https://groups.google.com/g/comp.std.c/c/pMaEU_8Rb7w
> _ _ _ _ _
> 2. strsep and strdup are not being added. strsep() is out because
> not enough people wanted it to vote it in; strdup() lost on the
> grounds that it would be the *ONLY* function other than *alloc()
> in the entire library whose return could be sanely passed to free(),
> and this is surprising.
> _ _ _ _ _
>
> Also: <https://stackoverflow.com/questions/32944390/what-is-the-rationale-
> for-not-including-strdup-in-the-c-standard>
>
> Anyway, pointed out that they can just use an initializer, something
> about which I was clued in by a friendly person in this very group.

strdup() and strndup() are being added to the C23 standard.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: avoiding strdup()

<20240310101101.00001fd4@yahoo.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51954&group=comp.lang.c#51954

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: already5chosen@yahoo.com (Michael S)
Newsgroups: comp.lang.c
Subject: Re: avoiding strdup()
Date: Sun, 10 Mar 2024 10:11:01 +0200
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <20240310101101.00001fd4@yahoo.com>
References: <us0brl$246bf$1@dont-email.me>
<pan$4fc39$61bdfbef$3ca9a71a$af842694@invalid.invalid>
<87y1ayj6hs.fsf_-_@bsb.me.uk>
<pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid>
<usc845$10v6e$1@dont-email.me>
<pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid>
<ushea7$28prq$2@dont-email.me>
<ushnkb$1rnlb$4@dont-email.me>
<87r0gizzuo.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="a901402e370eaa30848be77995d92c68";
logging-data="1078572"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19RW1X3YeBkV1VjHWzQpUQfcw6oK39AqwM="
Cancel-Lock: sha1:eGG5PgYv1vzKJOpaSvwolssUtc0=
X-Newsreader: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32)
 by: Michael S - Sun, 10 Mar 2024 08:11 UTC

On Sat, 09 Mar 2024 16:37:19 -0800
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

> vallor <vallor@cultnix.org> writes:
> [...]
> > Meanwhile, saw someone in another group write:
> >
> > char * something;
> > something = strdup("writable string etc.");
> > if( something == NULL ) { etc. }
> >
> > But that won't work if --std=c99, does work for g99 and c2x.
> > The (Linux) man page says:
> > /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200809L
> >
> > I asked Google about it being a POSIX extension
> > added at that late date, and it gave me an answer
> > about the C standard:
> >
> > "C9X London meeting update"
> > https://groups.google.com/g/comp.std.c/c/pMaEU_8Rb7w
> > _ _ _ _ _
> > 2. strsep and strdup are not being added. strsep() is out because
> > not enough people wanted it to vote it in; strdup() lost on the
> > grounds that it would be the *ONLY* function other than *alloc()
> > in the entire library whose return could be sanely passed to free(),
> > and this is surprising.
> > _ _ _ _ _
> >
> > Also:
> > <https://stackoverflow.com/questions/32944390/what-is-the-rationale-
> > for-not-including-strdup-in-the-c-standard>
> >
> > Anyway, pointed out that they can just use an initializer, something
> > about which I was clued in by a friendly person in this very group.
> >
>
> strdup() and strndup() are being added to the C23 standard.
>

What is justification?
What strdup() can do better, for any chosen value of better, than
strlen()+malloc()+memcpy() ?

Re: [OT] UTF-8 sig.

<20240310101757.0000345c@yahoo.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51955&group=comp.lang.c#51955

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: already5chosen@yahoo.com (Michael S)
Newsgroups: comp.lang.c
Subject: Re: [OT] UTF-8 sig.
Date: Sun, 10 Mar 2024 10:17:57 +0200
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <20240310101757.0000345c@yahoo.com>
References: <us0brl$246bf$1@dont-email.me>
<pan$4fc39$61bdfbef$3ca9a71a$af842694@invalid.invalid>
<87y1ayj6hs.fsf_-_@bsb.me.uk>
<pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid>
<usc845$10v6e$1@dont-email.me>
<pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid>
<ushea7$28prq$2@dont-email.me>
<pan$be9e9$95150fd$ee371059$7d065ee9@invalid.invalid>
<ushn58$2b111$1@dont-email.me>
<87o7bngczx.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="a901402e370eaa30848be77995d92c68";
logging-data="1078572"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+rC3Epz21l5sfpTThMbJ8z4fjmTISkrD0="
Cancel-Lock: sha1:OOQ0FuIfGmsvfH8pl35Kh3KGpiQ=
X-Newsreader: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32)
 by: Michael S - Sun, 10 Mar 2024 08:17 UTC

On Sun, 10 Mar 2024 00:13:38 +0000
Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:

> Richard Harnden <richard.nospam@gmail.invalid> writes:
>
> > On 09/03/2024 12:25, Blue-Maned_Hawk wrote:
> >> Ben wrote:
> ...
> >>>>> On Thu, 7 Mar 2024 06:48:19 -0000 (UTC), Blue-Maned_Hawk wrote:
> >>>>>
> >>>> It does not happen immediately; instead, the signature that the
> >>>> software saves gets more and more corrupted each time the
> >>>> software is opened.
> >>>
> >>> Do you mean the problem is not with Pan after all? "The
> >>> software" is deliberately vague and I don't know why Pan would be
> >>> saving the signature file. It just reads it as far as I can
> >>> tell.
> >>
> >> No, the problem is definitely with Pan. I don't know why it would
> >> be saving the signature file either, but it is.
> >
> > I think Ben has shown that it doesn't.
>
> I think BMH is not using a sig file. The bottom line is that pan can
> do what BMH wants, but he's doing something that does not work.
> Unfortunately his explanation is unhelpful because his sig (as posted)
> is not getting "more and more corrupted" so it's not at all clear what
> he's seeing.
>
> I've tried /not/ using a sig file and that also seems to work. The
> posting.xml configuration file /is/ written every time pan closes, but
> it appears not to be getting corrupted.
>

According to my understanding, one of his requirements is automatic
attachment of random rude phrase to the end of the signature.
Does your solution handle that?

Re: avoiding strdup()

<usk0er$2td02$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51956&group=comp.lang.c#51956

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: richard.nospam@gmail.invalid (Richard Harnden)
Newsgroups: comp.lang.c
Subject: Re: avoiding strdup()
Date: Sun, 10 Mar 2024 10:02:02 +0000
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <usk0er$2td02$1@dont-email.me>
References: <us0brl$246bf$1@dont-email.me>
<pan$4fc39$61bdfbef$3ca9a71a$af842694@invalid.invalid>
<87y1ayj6hs.fsf_-_@bsb.me.uk>
<pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid>
<usc845$10v6e$1@dont-email.me>
<pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid>
<ushea7$28prq$2@dont-email.me> <ushnkb$1rnlb$4@dont-email.me>
Reply-To: nospam.harnden@invalid.com
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 10 Mar 2024 10:02:03 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="08377d5e8277558f85a2b54dd370257a";
logging-data="3060738"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+G1oNfyZcTmY6YuyxyWB6JaOTCQdKeI8U="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:7E6ko5y7takKuGqnCsb1FNdpjLE=
Content-Language: en-GB
In-Reply-To: <ushnkb$1rnlb$4@dont-email.me>
 by: Richard Harnden - Sun, 10 Mar 2024 10:02 UTC

On 09/03/2024 13:19, vallor wrote:

>
> I asked Google about it [strdup] being a POSIX extension
> added at that late date, and it gave me an answer
> about the C standard:
>
> "C9X London meeting update"
> https://groups.google.com/g/comp.std.c/c/pMaEU_8Rb7w

That is from 1997

.... And shows just how useful a searchable usenet archive can be.
Pity google threw their toys out of the pram.

Re: [OT] UTF-8 sig.

<pan$16cc$8518f248$b52c2230$c54d4506@invalid.invalid>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51957&group=comp.lang.c#51957

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!bluemanedhawk.eternal-september.org!.POSTED!not-for-mail
From: bluemanedhawk@invalid.invalid (Blue-Maned_Hawk)
Newsgroups: comp.lang.c
Subject: Re: [OT] UTF-8 sig.
Date: Sun, 10 Mar 2024 13:35:08 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <pan$16cc$8518f248$b52c2230$c54d4506@invalid.invalid>
References: <us0brl$246bf$1@dont-email.me>
<pan$4fc39$61bdfbef$3ca9a71a$af842694@invalid.invalid>
<87y1ayj6hs.fsf_-_@bsb.me.uk>
<pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid>
<usc845$10v6e$1@dont-email.me>
<pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid>
<ushea7$28prq$2@dont-email.me>
<pan$be9e9$95150fd$ee371059$7d065ee9@invalid.invalid>
<ushn58$2b111$1@dont-email.me> <87o7bngczx.fsf@bsb.me.uk>
<20240310101757.0000345c@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 10 Mar 2024 13:35:08 -0000 (UTC)
Injection-Info: bluemanedhawk.eternal-september.org; posting-host="19bb270a84962846e11be7f5fbeb47d2";
logging-data="3142983"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+mOxfuLzLNucoZrwEKYBhyJwQOo9Z3LW4="
User-Agent: Pan/0.154 (Izium; 517acf4)
Cancel-Lock: sha1:Xlw492oGc/6GOiNhcqKtggqNXAI=
X-Face: LlanfairÂÂÂÂÂÂÂ
­pwllgwyngyllÂÂÂÂÂÃ
‚Â
? ?gogery­chwy
rn
­drobwllÃ
ƒƒƒ‚­llanÂ
? ?ƒƒƒƒ‚­tysilioÂÃ
? ?ƒ‚­gogoÂÂÃ
ƒƒ‚­goch
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACh0lEQVRYw71Z21bD
MAzzevbfkr4cHjrSXJyL044+MDa6WLEl2SkvkrZ1AbAvXO+bUGSCPYnsuIVGMpm
ZLnjX718GhAKNsp8lON2F9VrhELwIgJlBepkZjA78rVK+FkmNhEJK76UsJlz8+E
rJsjrpYouhLo/SC6qPHgakFOR8wV9+8rCfO/I/oVnmUZUp42/LW2XkLj9TCFNM9
jp5g2EmHZgpYZjCOkYU7sXVogRylJqpdggoFLG1g09Flah/7kErCxzR9HgXPYsq
0glb9cxjIz2Vsk9AmAoCSxECpD713joMKjQqLAtmMqJmXjdVvlMnMQCVITotJd1
z+fh1f1NNo+vuc1KnhWUmY7t03vydTud9BbXCtN3L2PL3bK7JCNG0GHzuZxafyB
fxevCxpm1vrwZltqw6SILCcdoCE6PGQC8wZWDA9Or7Qp5s3lAZezys0nDazs9S9
R0TjwEiksRxLkNPC1NMMWPs1bj0Ei0Yuo+JVtFLuzP1NRJ16qXWN8DhhtmS4PDg
O6mqRxs4bEJrYt087mSIow/1VzW2oFlMQuiuIy/KsUagvhdw6hSjJGlIavbLF8x
j3X47bccLcUSi0dkWh1nUZNhANT1tHKUXrNxNLbd9KPb9wDDVrKwmPQMOPQ1oy6
k5I1DwzDeRJd3jVIhDAUxq3ngzJG4CCkNXZxZVMcjefoK2J0gUY2S3rxz/RuTFx
2zHd9U+obimJXMG4edsk/2j5pTU5G1MmzbRLxkfq5EiT1GGsidvMGzi+1goGb2l
GCrN+nGnV8xj3q3JLRDVPL96vUc7Z4aJ3TN1mVqWAMJMfG+Jxh6TQqP+92iZkCU
xtglds1AB6r0aiSHKcnFck+p/c/0CbacFLQcajGcAAAAASUVORK5CYII=
 by: Blue-Maned_Hawk - Sun, 10 Mar 2024 13:35 UTC

Michael S wrote:

> According to my understanding, one of his requirements is automatic
> attachment of random rude phrase to the end of the signature.
> Does your solution handle that?

I do that manually, and i do not mean the phrases to be rude—if one of
them's been, please let me know and i'll prune it from further selection.

--
Blue-Maned_Hawk│shortens to Hawk│/blu.mɛin.dʰak/│he/him/his/himself/Mr.
blue-maned_hawk.srht.site
Ain't nobody's seen nothin' like that!

Re: avoiding strdup()

<pan$3ee01$922a1812$90fc3f75$bda42845@invalid.invalid>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51958&group=comp.lang.c#51958

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!bluemanedhawk.eternal-september.org!.POSTED!not-for-mail
From: bluemanedhawk@invalid.invalid (Blue-Maned_Hawk)
Newsgroups: comp.lang.c
Subject: Re: avoiding strdup()
Date: Sun, 10 Mar 2024 13:38:48 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <pan$3ee01$922a1812$90fc3f75$bda42845@invalid.invalid>
References: <us0brl$246bf$1@dont-email.me>
<pan$4fc39$61bdfbef$3ca9a71a$af842694@invalid.invalid>
<87y1ayj6hs.fsf_-_@bsb.me.uk>
<pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid>
<usc845$10v6e$1@dont-email.me>
<pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid>
<ushea7$28prq$2@dont-email.me> <ushnkb$1rnlb$4@dont-email.me>
<87r0gizzuo.fsf@nosuchdomain.example.com>
<20240310101101.00001fd4@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 10 Mar 2024 13:38:48 -0000 (UTC)
Injection-Info: bluemanedhawk.eternal-september.org; posting-host="19bb270a84962846e11be7f5fbeb47d2";
logging-data="3142983"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/EyylU4//yNHeefuFxFO1+B4DS+Zq4x3I="
User-Agent: Pan/0.154 (Izium; 517acf4)
Cancel-Lock: sha1:fbf1XbNCSkyfUYaiXkUONiVmfEM=
X-Face: LlanfairÂÂÂÂÂÂÂ
­pwllgwyngyllÂÂÂÂÂÃ
‚Â
? ?gogery­chwy
rn
­drobwllÃ
ƒƒƒ‚­llanÂ
? ?ƒƒƒƒ‚­tysilioÂÃ
? ?ƒ‚­gogoÂÂÃ
ƒƒ‚­goch
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACh0lEQVRYw71Z21bD
MAzzevbfkr4cHjrSXJyL044+MDa6WLEl2SkvkrZ1AbAvXO+bUGSCPYnsuIVGMpm
ZLnjX718GhAKNsp8lON2F9VrhELwIgJlBepkZjA78rVK+FkmNhEJK76UsJlz8+E
rJsjrpYouhLo/SC6qPHgakFOR8wV9+8rCfO/I/oVnmUZUp42/LW2XkLj9TCFNM9
jp5g2EmHZgpYZjCOkYU7sXVogRylJqpdggoFLG1g09Flah/7kErCxzR9HgXPYsq
0glb9cxjIz2Vsk9AmAoCSxECpD713joMKjQqLAtmMqJmXjdVvlMnMQCVITotJd1
z+fh1f1NNo+vuc1KnhWUmY7t03vydTud9BbXCtN3L2PL3bK7JCNG0GHzuZxafyB
fxevCxpm1vrwZltqw6SILCcdoCE6PGQC8wZWDA9Or7Qp5s3lAZezys0nDazs9S9
R0TjwEiksRxLkNPC1NMMWPs1bj0Ei0Yuo+JVtFLuzP1NRJ16qXWN8DhhtmS4PDg
O6mqRxs4bEJrYt087mSIow/1VzW2oFlMQuiuIy/KsUagvhdw6hSjJGlIavbLF8x
j3X47bccLcUSi0dkWh1nUZNhANT1tHKUXrNxNLbd9KPb9wDDVrKwmPQMOPQ1oy6
k5I1DwzDeRJd3jVIhDAUxq3ngzJG4CCkNXZxZVMcjefoK2J0gUY2S3rxz/RuTFx
2zHd9U+obimJXMG4edsk/2j5pTU5G1MmzbRLxkfq5EiT1GGsidvMGzi+1goGb2l
GCrN+nGnV8xj3q3JLRDVPL96vUc7Z4aJ3TN1mVqWAMJMfG+Jxh6TQqP+92iZkCU
xtglds1AB6r0aiSHKcnFck+p/c/0CbacFLQcajGcAAAAASUVORK5CYII=
 by: Blue-Maned_Hawk - Sun, 10 Mar 2024 13:38 UTC

Michael S wrote:

> What strdup() can do better, for any chosen value of better, than
> strlen()+malloc()+memcpy() ?

It's shorter.

--
Blue-Maned_Hawk│shortens to Hawk│/blu.mɛin.dʰak/│he/him/his/himself/Mr.
blue-maned_hawk.srht.site
The logical conclusion of “don't repeat yourself” is to never say
anything.

Re: [OT] UTF-8 sig.

<87il1ugp4i.fsf@bsb.me.uk>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51959&group=comp.lang.c#51959

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: [OT] UTF-8 sig.
Date: Sun, 10 Mar 2024 14:03:57 +0000
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <87il1ugp4i.fsf@bsb.me.uk>
References: <us0brl$246bf$1@dont-email.me>
<pan$4fc39$61bdfbef$3ca9a71a$af842694@invalid.invalid>
<87y1ayj6hs.fsf_-_@bsb.me.uk>
<pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid>
<usc845$10v6e$1@dont-email.me>
<pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid>
<ushea7$28prq$2@dont-email.me> <ushiov$2a6en$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="cede268a02bc27bff115d4df3163c235";
logging-data="3142956"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ARZsM6GFV0HSI6QZbbXg0+W44j2n46yY="
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:EoomO+HftJr46gDW84odif03YQA=
sha1:7vClblmWhZKvy0RWPebNWAX/nk0=
X-BSB-Auth: 1.0c6bdbefaeefe9ad2733.20240310140357GMT.87il1ugp4i.fsf@bsb.me.uk
 by: Ben Bacarisse - Sun, 10 Mar 2024 14:03 UTC

Richard Harnden <richard.nospam@gmail.invalid> writes:

> On 09/03/2024 10:40, Ben wrote:
>> [working sig]
>
> Since you have utf8/ipa working, I don't suppose you could say how to
> pronounce your surname? I know I get it wrong. I'm pretty sure I don't
> even get close.

In English: 'bækəriːs, in French more like baka'ris. (IPA looks horrid
in most software because a mixture of fonts is often used.)

--
Ben.

Re: avoiding strdup()

<20240310100715.866@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51960&group=comp.lang.c#51960

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-6894@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: avoiding strdup()
Date: Sun, 10 Mar 2024 17:12:42 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <20240310100715.866@kylheku.com>
References: <us0brl$246bf$1@dont-email.me>
<pan$4fc39$61bdfbef$3ca9a71a$af842694@invalid.invalid>
<87y1ayj6hs.fsf_-_@bsb.me.uk>
<pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid>
<usc845$10v6e$1@dont-email.me>
<pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid>
<ushea7$28prq$2@dont-email.me> <ushnkb$1rnlb$4@dont-email.me>
<87r0gizzuo.fsf@nosuchdomain.example.com>
<20240310101101.00001fd4@yahoo.com>
Injection-Date: Sun, 10 Mar 2024 17:12:42 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ee7bdc3293676d3017c029b03873f9fc";
logging-data="3233986"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+F6Yl4wlnkElQmfe69Ou4wlSyAexghSgs="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:+MyYlpQQjYfi6UhyBu/hxU+lT6Y=
 by: Kaz Kylheku - Sun, 10 Mar 2024 17:12 UTC

On 2024-03-10, Michael S <already5chosen@yahoo.com> wrote:
> On Sat, 09 Mar 2024 16:37:19 -0800
> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> strdup() and strndup() are being added to the C23 standard.
>>
>
> What is justification?

strdup is required by POSIX already and thus widely implemented.
Many programmers who are not into standards already assume it's in C.

For decades, portable programs have been doing things like this:

#if HAVE_STRDUP
#define xstrdup(s) strdup(s)
#else
char *xstrdup(const char *); // own definition
#endif

> What strdup() can do better, for any chosen value of better, than
> strlen()+malloc()+memcpy() ?

Not take up space in every application for a common library routine.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: [OT] UTF-8 sig.

<20240310101349.261@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51961&group=comp.lang.c#51961

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-6894@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: [OT] UTF-8 sig.
Date: Sun, 10 Mar 2024 17:15:10 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <20240310101349.261@kylheku.com>
References: <us0brl$246bf$1@dont-email.me>
<pan$4fc39$61bdfbef$3ca9a71a$af842694@invalid.invalid>
<87y1ayj6hs.fsf_-_@bsb.me.uk>
<pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid>
<usc845$10v6e$1@dont-email.me>
<pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid>
<ushea7$28prq$2@dont-email.me>
<pan$be9e9$95150fd$ee371059$7d065ee9@invalid.invalid>
<ushn58$2b111$1@dont-email.me> <87o7bngczx.fsf@bsb.me.uk>
<20240310101757.0000345c@yahoo.com>
Injection-Date: Sun, 10 Mar 2024 17:15:10 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ee7bdc3293676d3017c029b03873f9fc";
logging-data="3233986"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+8w04qG2t0x4Ws1OCcPb6d/x5MGYorpkE="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:F0JCfYH8dNbglMG7LjFElTMOtLI=
 by: Kaz Kylheku - Sun, 10 Mar 2024 17:15 UTC

On 2024-03-10, Michael S <already5chosen@yahoo.com> wrote:
> According to my understanding, one of his requirements is automatic
> attachment of random rude phrase to the end of the signature.
> Does your solution handle that?

You can run a cron job that updates the signature file with random
content once every so many minutes. Probably daily would be fine.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: avoiding strdup()

<ifnHN.386274$vFZa.250421@fx13.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51962&group=comp.lang.c#51962

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx13.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: avoiding strdup()
Newsgroups: comp.lang.c
References: <us0brl$246bf$1@dont-email.me> <pan$4fc39$61bdfbef$3ca9a71a$af842694@invalid.invalid> <87y1ayj6hs.fsf_-_@bsb.me.uk> <pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid> <usc845$10v6e$1@dont-email.me> <pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid> <ushea7$28prq$2@dont-email.me> <ushnkb$1rnlb$4@dont-email.me> <87r0gizzuo.fsf@nosuchdomain.example.com> <20240310101101.00001fd4@yahoo.com> <20240310100715.866@kylheku.com>
Lines: 28
Message-ID: <ifnHN.386274$vFZa.250421@fx13.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sun, 10 Mar 2024 18:47:42 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sun, 10 Mar 2024 18:47:42 GMT
X-Received-Bytes: 1935
 by: Scott Lurndal - Sun, 10 Mar 2024 18:47 UTC

Kaz Kylheku <433-929-6894@kylheku.com> writes:
>On 2024-03-10, Michael S <already5chosen@yahoo.com> wrote:
>> On Sat, 09 Mar 2024 16:37:19 -0800
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>> strdup() and strndup() are being added to the C23 standard.
>>>
>>
>> What is justification?
>
>strdup is required by POSIX already and thus widely implemented.
>Many programmers who are not into standards already assume it's in C.
>
>For decades, portable programs have been doing things like this:
>
>#if HAVE_STRDUP
>#define xstrdup(s) strdup(s)
>#else
>char *xstrdup(const char *); // own definition
>#endif
>
>> What strdup() can do better, for any chosen value of better, than
>> strlen()+malloc()+memcpy() ?
>
>Not take up space in every application for a common library routine.

It's a form of lazy programming. I've seen a lot of open source
code that uses strdup without checking for failure and frequently
"forgetting" to free the result.

Re: [OT] UTF-8 sig.

<usl0ds$347ev$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51963&group=comp.lang.c#51963

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: richard.nospam@gmail.invalid (Richard Harnden)
Newsgroups: comp.lang.c
Subject: Re: [OT] UTF-8 sig.
Date: Sun, 10 Mar 2024 19:07:40 +0000
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <usl0ds$347ev$1@dont-email.me>
References: <us0brl$246bf$1@dont-email.me>
<pan$4fc39$61bdfbef$3ca9a71a$af842694@invalid.invalid>
<87y1ayj6hs.fsf_-_@bsb.me.uk>
<pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid>
<usc845$10v6e$1@dont-email.me>
<pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid>
<ushea7$28prq$2@dont-email.me> <ushiov$2a6en$1@dont-email.me>
<87il1ugp4i.fsf@bsb.me.uk>
Reply-To: nospam.harnden@invalid.com
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 10 Mar 2024 19:07:41 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="08377d5e8277558f85a2b54dd370257a";
logging-data="3284447"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/5SHmZqxMQNqFvO90DGf9C7cyQK10Mffo="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:fRRftmqEXU+/fxxg110Gt8/TEv0=
In-Reply-To: <87il1ugp4i.fsf@bsb.me.uk>
Content-Language: en-GB
 by: Richard Harnden - Sun, 10 Mar 2024 19:07 UTC

On 10/03/2024 14:03, Ben Bacarisse wrote:
> Richard Harnden <richard.nospam@gmail.invalid> writes:
>
>> On 09/03/2024 10:40, Ben wrote:
>>> [working sig]
>>
>> Since you have utf8/ipa working, I don't suppose you could say how to
>> pronounce your surname? I know I get it wrong. I'm pretty sure I don't
>> even get close.
>
> In English: 'bækəriːs, in French more like baka'ris. (IPA looks horrid
> in most software because a mixture of fonts is often used.)
>

Thanks.

Re: avoiding strdup()

<usl150$347ev$2@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51964&group=comp.lang.c#51964

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.nntp4.net!news.gegeweb.eu!gegeweb.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: richard.nospam@gmail.invalid (Richard Harnden)
Newsgroups: comp.lang.c
Subject: Re: avoiding strdup()
Date: Sun, 10 Mar 2024 19:20:00 +0000
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <usl150$347ev$2@dont-email.me>
References: <us0brl$246bf$1@dont-email.me>
<pan$4fc39$61bdfbef$3ca9a71a$af842694@invalid.invalid>
<87y1ayj6hs.fsf_-_@bsb.me.uk>
<pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid>
<usc845$10v6e$1@dont-email.me>
<pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid>
<ushea7$28prq$2@dont-email.me> <ushnkb$1rnlb$4@dont-email.me>
<87r0gizzuo.fsf@nosuchdomain.example.com> <20240310101101.00001fd4@yahoo.com>
<20240310100715.866@kylheku.com> <ifnHN.386274$vFZa.250421@fx13.iad>
Reply-To: nospam.harnden@invalid.com
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 10 Mar 2024 19:20:00 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="08377d5e8277558f85a2b54dd370257a";
logging-data="3284447"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX194F0kBGwwdjKrkO1smnwUivefSJQIOJmw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:V6UKvdQmjDSuF0TNYsFoDXakkzk=
Content-Language: en-GB
In-Reply-To: <ifnHN.386274$vFZa.250421@fx13.iad>
 by: Richard Harnden - Sun, 10 Mar 2024 19:20 UTC

On 10/03/2024 18:47, Scott Lurndal wrote:
> Kaz Kylheku <433-929-6894@kylheku.com> writes:
>> On 2024-03-10, Michael S <already5chosen@yahoo.com> wrote:
>>> On Sat, 09 Mar 2024 16:37:19 -0800
>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>>> strdup() and strndup() are being added to the C23 standard.
>>>>
>>>
>>> What is justification?
>>
>> strdup is required by POSIX already and thus widely implemented.
>> Many programmers who are not into standards already assume it's in C.
>>
>> For decades, portable programs have been doing things like this:
>>
>> #if HAVE_STRDUP
>> #define xstrdup(s) strdup(s)
>> #else
>> char *xstrdup(const char *); // own definition
>> #endif
>>
>>> What strdup() can do better, for any chosen value of better, than
>>> strlen()+malloc()+memcpy() ?
>>
>> Not take up space in every application for a common library routine.
>
> It's a form of lazy programming. I've seen a lot of open source
> code that uses strdup without checking for failure and frequently
> "forgetting" to free the result.

The hidden use of malloc was one of the reasons it was left out of the
standard library.

Re: avoiding strdup()

<usnb64$3n297$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51965&group=comp.lang.c#51965

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: malcolm.arthur.mclean@gmail.com (Malcolm McLean)
Newsgroups: comp.lang.c
Subject: Re: avoiding strdup()
Date: Mon, 11 Mar 2024 16:23:32 +0000
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <usnb64$3n297$1@dont-email.me>
References: <us0brl$246bf$1@dont-email.me>
<pan$4fc39$61bdfbef$3ca9a71a$af842694@invalid.invalid>
<87y1ayj6hs.fsf_-_@bsb.me.uk>
<pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid>
<usc845$10v6e$1@dont-email.me>
<pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid>
<ushea7$28prq$2@dont-email.me> <ushnkb$1rnlb$4@dont-email.me>
<87r0gizzuo.fsf@nosuchdomain.example.com> <20240310101101.00001fd4@yahoo.com>
<20240310100715.866@kylheku.com> <ifnHN.386274$vFZa.250421@fx13.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 11 Mar 2024 16:23:33 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0ba131241a3ca99c5f1624325e7f91d4";
logging-data="3901735"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18MmYEyXwV4+zQ5+BDk6VzBuhskDPSm4Qw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:38tnRvMHsCu8NABLt8b+X/u+QbQ=
Content-Language: en-GB
In-Reply-To: <ifnHN.386274$vFZa.250421@fx13.iad>
 by: Malcolm McLean - Mon, 11 Mar 2024 16:23 UTC

On 10/03/2024 18:47, Scott Lurndal wrote:
> Kaz Kylheku <433-929-6894@kylheku.com> writes:
>> On 2024-03-10, Michael S <already5chosen@yahoo.com> wrote:
>>> On Sat, 09 Mar 2024 16:37:19 -0800
>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>>> strdup() and strndup() are being added to the C23 standard.
>>>>
>>>
>>> What is justification?
>>
>> strdup is required by POSIX already and thus widely implemented.
>> Many programmers who are not into standards already assume it's in C.
>>
>> For decades, portable programs have been doing things like this:
>>
>> #if HAVE_STRDUP
>> #define xstrdup(s) strdup(s)
>> #else
>> char *xstrdup(const char *); // own definition
>> #endif
>>
>>> What strdup() can do better, for any chosen value of better, than
>>> strlen()+malloc()+memcpy() ?
>>
>> Not take up space in every application for a common library routine.
>
> It's a form of lazy programming. I've seen a lot of open source
> code that uses strdup without checking for failure and frequently
> "forgetting" to free the result.

And it is probably more likely that machine with many gigabytes of RAM
will develop an electrical fault than that that call for a short string
will be the point where it runs out of memory.
--
Check out Basic Algorithms and my other books:
https://www.lulu.com/spotlight/bgy1mm

Re: avoiding strdup()

<20240311185039.000066fc@yahoo.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51966&group=comp.lang.c#51966

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: already5chosen@yahoo.com (Michael S)
Newsgroups: comp.lang.c
Subject: Re: avoiding strdup()
Date: Mon, 11 Mar 2024 18:50:39 +0200
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <20240311185039.000066fc@yahoo.com>
References: <us0brl$246bf$1@dont-email.me>
<pan$4fc39$61bdfbef$3ca9a71a$af842694@invalid.invalid>
<87y1ayj6hs.fsf_-_@bsb.me.uk>
<pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid>
<usc845$10v6e$1@dont-email.me>
<pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid>
<ushea7$28prq$2@dont-email.me>
<ushnkb$1rnlb$4@dont-email.me>
<87r0gizzuo.fsf@nosuchdomain.example.com>
<20240310101101.00001fd4@yahoo.com>
<20240310100715.866@kylheku.com>
<ifnHN.386274$vFZa.250421@fx13.iad>
<usnb64$3n297$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="20135147cba2d202cd079ad5c3141fdd";
logging-data="3784551"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+k5midifdyNXJ8We7OfKzn4+O8fOcobz8="
Cancel-Lock: sha1:WodFPq4vn9SryrsQ34vqvamwTDU=
X-Newsreader: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32)
 by: Michael S - Mon, 11 Mar 2024 16:50 UTC

On Mon, 11 Mar 2024 16:23:32 +0000
Malcolm McLean <malcolm.arthur.mclean@gmail.com> wrote:

> On 10/03/2024 18:47, Scott Lurndal wrote:
> > Kaz Kylheku <433-929-6894@kylheku.com> writes:
> >> On 2024-03-10, Michael S <already5chosen@yahoo.com> wrote:
> >>> On Sat, 09 Mar 2024 16:37:19 -0800
> >>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> >>>> strdup() and strndup() are being added to the C23 standard.
> >>>>
> >>>
> >>> What is justification?
> >>
> >> strdup is required by POSIX already and thus widely implemented.
> >> Many programmers who are not into standards already assume it's in
> >> C.
> >>
> >> For decades, portable programs have been doing things like this:
> >>
> >> #if HAVE_STRDUP
> >> #define xstrdup(s) strdup(s)
> >> #else
> >> char *xstrdup(const char *); // own definition
> >> #endif
> >>
> >>> What strdup() can do better, for any chosen value of better, than
> >>> strlen()+malloc()+memcpy() ?
> >>
> >> Not take up space in every application for a common library
> >> routine.
> >
> > It's a form of lazy programming. I've seen a lot of open source
> > code that uses strdup without checking for failure and frequently
> > "forgetting" to free the result.
>
> And it is probably more likely that machine with many gigabytes of
> RAM will develop an electrical fault than that that call for a short
> string will be the point where it runs out of memory.

Is there any chance at all that on typical Linux machine (i.e. the one
configured to overcommit virtual memory) strdup() returns NULL?
If it was malloc() I'd say - no chance. For strdup() I'm less sure.

Re: avoiding strdup()

<yMGHN.481214$PuZ9.381006@fx11.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51967&group=comp.lang.c#51967

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!newsfeed.endofthelinebbs.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx11.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: avoiding strdup()
Newsgroups: comp.lang.c
References: <us0brl$246bf$1@dont-email.me> <pan$4fc39$61bdfbef$3ca9a71a$af842694@invalid.invalid> <87y1ayj6hs.fsf_-_@bsb.me.uk> <pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid> <usc845$10v6e$1@dont-email.me> <pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid> <ushea7$28prq$2@dont-email.me> <ushnkb$1rnlb$4@dont-email.me> <87r0gizzuo.fsf@nosuchdomain.example.com> <20240310101101.00001fd4@yahoo.com> <20240310100715.866@kylheku.com> <ifnHN.386274$vFZa.250421@fx13.iad> <usnb64$3n297$1@dont-email.me>
Lines: 41
Message-ID: <yMGHN.481214$PuZ9.381006@fx11.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Mon, 11 Mar 2024 17:00:14 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Mon, 11 Mar 2024 17:00:14 GMT
X-Received-Bytes: 2531
 by: Scott Lurndal - Mon, 11 Mar 2024 17:00 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>On 10/03/2024 18:47, Scott Lurndal wrote:
>> Kaz Kylheku <433-929-6894@kylheku.com> writes:
>>> On 2024-03-10, Michael S <already5chosen@yahoo.com> wrote:
>>>> On Sat, 09 Mar 2024 16:37:19 -0800
>>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>>>> strdup() and strndup() are being added to the C23 standard.
>>>>>
>>>>
>>>> What is justification?
>>>
>>> strdup is required by POSIX already and thus widely implemented.
>>> Many programmers who are not into standards already assume it's in C.
>>>
>>> For decades, portable programs have been doing things like this:
>>>
>>> #if HAVE_STRDUP
>>> #define xstrdup(s) strdup(s)
>>> #else
>>> char *xstrdup(const char *); // own definition
>>> #endif
>>>
>>>> What strdup() can do better, for any chosen value of better, than
>>>> strlen()+malloc()+memcpy() ?
>>>
>>> Not take up space in every application for a common library routine.
>>
>> It's a form of lazy programming. I've seen a lot of open source
>> code that uses strdup without checking for failure and frequently
>> "forgetting" to free the result.
>
>And it is probably more likely that machine with many gigabytes of RAM

Actually, your assumptions that:
1) strdup is the only allocation function used by an application
2) all strings are "short"

are both flawed.

>will develop an electrical fault than that that call for a short string
>will be the point where it runs out of memory.

Re: avoiding strdup()

<ERGHN.481215$PuZ9.417692@fx11.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51968&group=comp.lang.c#51968

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx11.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: avoiding strdup()
Newsgroups: comp.lang.c
References: <us0brl$246bf$1@dont-email.me> <87y1ayj6hs.fsf_-_@bsb.me.uk> <pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid> <usc845$10v6e$1@dont-email.me> <pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid> <ushea7$28prq$2@dont-email.me> <ushnkb$1rnlb$4@dont-email.me> <87r0gizzuo.fsf@nosuchdomain.example.com> <20240310101101.00001fd4@yahoo.com> <20240310100715.866@kylheku.com> <ifnHN.386274$vFZa.250421@fx13.iad> <usnb64$3n297$1@dont-email.me> <20240311185039.000066fc@yahoo.com>
Lines: 62
Message-ID: <ERGHN.481215$PuZ9.417692@fx11.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Mon, 11 Mar 2024 17:05:40 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Mon, 11 Mar 2024 17:05:40 GMT
X-Received-Bytes: 3579
 by: Scott Lurndal - Mon, 11 Mar 2024 17:05 UTC

Michael S <already5chosen@yahoo.com> writes:
>On Mon, 11 Mar 2024 16:23:32 +0000
>Malcolm McLean <malcolm.arthur.mclean@gmail.com> wrote:
>
>> On 10/03/2024 18:47, Scott Lurndal wrote:
>> > Kaz Kylheku <433-929-6894@kylheku.com> writes:
>> >> On 2024-03-10, Michael S <already5chosen@yahoo.com> wrote:
>> >>> On Sat, 09 Mar 2024 16:37:19 -0800
>> >>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> >>>> strdup() and strndup() are being added to the C23 standard.
>> >>>>
>> >>>
>> >>> What is justification?
>> >>
>> >> strdup is required by POSIX already and thus widely implemented.
>> >> Many programmers who are not into standards already assume it's in
>> >> C.
>> >>
>> >> For decades, portable programs have been doing things like this:
>> >>
>> >> #if HAVE_STRDUP
>> >> #define xstrdup(s) strdup(s)
>> >> #else
>> >> char *xstrdup(const char *); // own definition
>> >> #endif
>> >>
>> >>> What strdup() can do better, for any chosen value of better, than
>> >>> strlen()+malloc()+memcpy() ?
>> >>
>> >> Not take up space in every application for a common library
>> >> routine.
>> >
>> > It's a form of lazy programming. I've seen a lot of open source
>> > code that uses strdup without checking for failure and frequently
>> > "forgetting" to free the result.
>>
>> And it is probably more likely that machine with many gigabytes of
>> RAM will develop an electrical fault than that that call for a short
>> string will be the point where it runs out of memory.
>
>Is there any chance at all that on typical Linux machine (i.e. the one
>configured to overcommit virtual memory) strdup() returns NULL?
>If it was malloc() I'd say - no chance. For strdup() I'm less sure.
>

An unanswerable question. But, consider that not all allocations
in an application use strdup as the only memory allocator (the majority don't,
and other allocations may be much larger), yet both use the same pool of
address space and host memory.

Consider also that on unix and linux, there are a number of resource limits
intended to prevent a single application from consuming all of
memory, which a call to strdup may encounter even with plenty of RAM
available.

Toy applications may not have an issue with strdup. Real applications
on the other hand might, and an unexpected SIGSEGV is extremely
user-unfriendly and could have catastrophic results.

And on the gripping hand, not testing for a potential catastrophic
failure condition, no matter how unlikely isn't the sign of a good
programmer.

Re: avoiding strdup()

<87edcgzo7r.fsf@nosuchdomain.example.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51969&group=comp.lang.c#51969

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: avoiding strdup()
Date: Mon, 11 Mar 2024 10:13:12 -0700
Organization: None to speak of
Lines: 18
Message-ID: <87edcgzo7r.fsf@nosuchdomain.example.com>
References: <us0brl$246bf$1@dont-email.me>
<pan$4fc39$61bdfbef$3ca9a71a$af842694@invalid.invalid>
<87y1ayj6hs.fsf_-_@bsb.me.uk>
<pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid>
<usc845$10v6e$1@dont-email.me>
<pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid>
<ushea7$28prq$2@dont-email.me> <ushnkb$1rnlb$4@dont-email.me>
<87r0gizzuo.fsf@nosuchdomain.example.com>
<20240310101101.00001fd4@yahoo.com> <20240310100715.866@kylheku.com>
<ifnHN.386274$vFZa.250421@fx13.iad> <usnb64$3n297$1@dont-email.me>
<20240311185039.000066fc@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="803e1d91970c7135fb6b17cffb70db2d";
logging-data="3926617"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+whw99owjRbDpElP5si8ec"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:kidG1B9f5agIz46gWQB2unQqfEQ=
sha1:AsvIiYSFwS8tseUWsEh7Sl+NNw4=
 by: Keith Thompson - Mon, 11 Mar 2024 17:13 UTC

Michael S <already5chosen@yahoo.com> writes:
[...]
> Is there any chance at all that on typical Linux machine (i.e. the one
> configured to overcommit virtual memory) strdup() returns NULL?
> If it was malloc() I'd say - no chance. For strdup() I'm less sure.

strdup() calls malloc(), so strdup() can return NULL if and only if
malloc() can return NULL -- but with the additional constraint that you
first need to have a string argument to strdup() that's long enough to
cause a suffiently large argument to be passed to malloc().

One data point: On my Ubuntu system, malloc(SIZE_MAX) returns NULL for
very large arguments (over about 23 GiB in my quick and dirty test).

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: avoiding strdup()

<20240311193511.0000610f@yahoo.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51970&group=comp.lang.c#51970

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: already5chosen@yahoo.com (Michael S)
Newsgroups: comp.lang.c
Subject: Re: avoiding strdup()
Date: Mon, 11 Mar 2024 19:35:11 +0200
Organization: A noiseless patient Spider
Lines: 93
Message-ID: <20240311193511.0000610f@yahoo.com>
References: <us0brl$246bf$1@dont-email.me>
<87y1ayj6hs.fsf_-_@bsb.me.uk>
<pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid>
<usc845$10v6e$1@dont-email.me>
<pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid>
<ushea7$28prq$2@dont-email.me>
<ushnkb$1rnlb$4@dont-email.me>
<87r0gizzuo.fsf@nosuchdomain.example.com>
<20240310101101.00001fd4@yahoo.com>
<20240310100715.866@kylheku.com>
<ifnHN.386274$vFZa.250421@fx13.iad>
<usnb64$3n297$1@dont-email.me>
<20240311185039.000066fc@yahoo.com>
<ERGHN.481215$PuZ9.417692@fx11.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="20135147cba2d202cd079ad5c3141fdd";
logging-data="3784551"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+KKvgM6JmT+jTZ6VjCAIiYlJ6lYHEuF8s="
Cancel-Lock: sha1:+7qVM4tZskJPJAJEdx9EPHbBVqM=
X-Newsreader: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32)
 by: Michael S - Mon, 11 Mar 2024 17:35 UTC

On Mon, 11 Mar 2024 17:05:40 GMT
scott@slp53.sl.home (Scott Lurndal) wrote:

> Michael S <already5chosen@yahoo.com> writes:
> >On Mon, 11 Mar 2024 16:23:32 +0000
> >Malcolm McLean <malcolm.arthur.mclean@gmail.com> wrote:
> >
> >> On 10/03/2024 18:47, Scott Lurndal wrote:
> >> > Kaz Kylheku <433-929-6894@kylheku.com> writes:
> >> >> On 2024-03-10, Michael S <already5chosen@yahoo.com> wrote:
> >> >>> On Sat, 09 Mar 2024 16:37:19 -0800
> >> >>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> >> >>>> strdup() and strndup() are being added to the C23 standard.
> >> >>>>
> >> >>>
> >> >>> What is justification?
> >> >>
> >> >> strdup is required by POSIX already and thus widely implemented.
> >> >> Many programmers who are not into standards already assume it's
> >> >> in C.
> >> >>
> >> >> For decades, portable programs have been doing things like this:
> >> >>
> >> >> #if HAVE_STRDUP
> >> >> #define xstrdup(s) strdup(s)
> >> >> #else
> >> >> char *xstrdup(const char *); // own definition
> >> >> #endif
> >> >>
> >> >>> What strdup() can do better, for any chosen value of better,
> >> >>> than strlen()+malloc()+memcpy() ?
> >> >>
> >> >> Not take up space in every application for a common library
> >> >> routine.
> >> >
> >> > It's a form of lazy programming. I've seen a lot of open source
> >> > code that uses strdup without checking for failure and frequently
> >> > "forgetting" to free the result.
> >>
> >> And it is probably more likely that machine with many gigabytes of
> >> RAM will develop an electrical fault than that that call for a
> >> short string will be the point where it runs out of memory.
> >
> >Is there any chance at all that on typical Linux machine (i.e. the
> >one configured to overcommit virtual memory) strdup() returns NULL?
> >If it was malloc() I'd say - no chance. For strdup() I'm less sure.
> >
>
> An unanswerable question. But, consider that not all allocations
> in an application use strdup as the only memory allocator (the
> majority don't, and other allocations may be much larger), yet both
> use the same pool of address space and host memory.
>
> Consider also that on unix and linux, there are a number of resource
> limits intended to prevent a single application from consuming all of
> memory, which a call to strdup may encounter even with plenty of RAM
> available.
>
> Toy applications may not have an issue with strdup. Real
> applications on the other hand might, and an unexpected SIGSEGV is
> extremely user-unfriendly and could have catastrophic results.
>

According to my understanding, on Linux with overcommit enabled,
typical behavior would be that allocation (of non-extravagant size,
say, no more than 100 MB) always succeeds. OOM is called later, on
access. It seems, that most commonly OOM does not hit application that
is allocating right now. Much more likely that it will kill app that
user opened hours ago, then put aside and then tried to use again.

> And on the gripping hand, not testing for a potential catastrophic
> failure condition, no matter how unlikely isn't the sign of a good
> programmer.

Some people would say that writing code (a handler for allocation
returning NULL) that either can't be tested in principle or can be
tested only in principle, but most certainly not tested in
practice, isn't a sign of a good programmer.
Myself, I still tend to code this checks, but
(1) my main targets are not Linux with overcommit, so the
chance of allocation returning NULL could be estimated like "not going
to happen" rather than "can't happen".
(2) I am old full that like his unreasonable old habits

At least, I stopped checking return value of fclose() after being told,
with facts, how stupid it is. So, may be, one day I'd convince myself to
stop checking return value of malloc() as well.

Re: avoiding strdup()

<20240311104527.444@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51971&group=comp.lang.c#51971

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-6894@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: avoiding strdup()
Date: Mon, 11 Mar 2024 17:52:44 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <20240311104527.444@kylheku.com>
References: <us0brl$246bf$1@dont-email.me>
<pan$4fc39$61bdfbef$3ca9a71a$af842694@invalid.invalid>
<87y1ayj6hs.fsf_-_@bsb.me.uk>
<pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid>
<usc845$10v6e$1@dont-email.me>
<pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid>
<ushea7$28prq$2@dont-email.me> <ushnkb$1rnlb$4@dont-email.me>
<87r0gizzuo.fsf@nosuchdomain.example.com>
<20240310101101.00001fd4@yahoo.com> <20240310100715.866@kylheku.com>
<ifnHN.386274$vFZa.250421@fx13.iad> <usnb64$3n297$1@dont-email.me>
<yMGHN.481214$PuZ9.381006@fx11.iad>
Injection-Date: Mon, 11 Mar 2024 17:52:44 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2dfcac18fd004bfc05446b2cad7a6cb1";
logging-data="3941503"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+J9Tr6UQb6/VJ5qENJ0Y7bqVWtOOWW61M="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:QBOQcpeUJaK5O1hyoWH7nc6aC/E=
 by: Kaz Kylheku - Mon, 11 Mar 2024 17:52 UTC

On 2024-03-11, Scott Lurndal <scott@slp53.sl.home> wrote:
> Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>>On 10/03/2024 18:47, Scott Lurndal wrote:
>>> Kaz Kylheku <433-929-6894@kylheku.com> writes:
>>>> Not take up space in every application for a common library routine.
>>>
>>> It's a form of lazy programming. I've seen a lot of open source
>>> code that uses strdup without checking for failure and frequently
>>> "forgetting" to free the result.
>>
>>And it is probably more likely that machine with many gigabytes of RAM
>
> Actually, your assumptions that:
> 1) strdup is the only allocation function used by an application
> 2) all strings are "short"

Even if a string is long enough to need its own mmap request,
that will still return valid memory that later fails to commit.

Under overcommit conditions, you will only reliably get null return out
of a large strdup if you've exhausted your local address space
(of which you have lots under 64 bits).

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: avoiding strdup()

<20240311105508.215@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51972&group=comp.lang.c#51972

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-6894@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: avoiding strdup()
Date: Mon, 11 Mar 2024 17:58:03 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <20240311105508.215@kylheku.com>
References: <us0brl$246bf$1@dont-email.me>
<pan$4fc39$61bdfbef$3ca9a71a$af842694@invalid.invalid>
<87y1ayj6hs.fsf_-_@bsb.me.uk>
<pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid>
<usc845$10v6e$1@dont-email.me>
<pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid>
<ushea7$28prq$2@dont-email.me> <ushnkb$1rnlb$4@dont-email.me>
<87r0gizzuo.fsf@nosuchdomain.example.com>
<20240310101101.00001fd4@yahoo.com> <20240310100715.866@kylheku.com>
<ifnHN.386274$vFZa.250421@fx13.iad> <usnb64$3n297$1@dont-email.me>
<20240311185039.000066fc@yahoo.com>
<87edcgzo7r.fsf@nosuchdomain.example.com>
Injection-Date: Mon, 11 Mar 2024 17:58:03 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2dfcac18fd004bfc05446b2cad7a6cb1";
logging-data="3941503"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/BfX+3Nu3o7DwPEq8Cd4H/Y1VIQhN9p1E="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:abYAr1ghfBd3g+1LgpI5ZxmeN1U=
 by: Kaz Kylheku - Mon, 11 Mar 2024 17:58 UTC

On 2024-03-11, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> Michael S <already5chosen@yahoo.com> writes:
> [...]
>> Is there any chance at all that on typical Linux machine (i.e. the one
>> configured to overcommit virtual memory) strdup() returns NULL?
>> If it was malloc() I'd say - no chance. For strdup() I'm less sure.
>
> strdup() calls malloc(), so strdup() can return NULL if and only if
> malloc() can return NULL -- but with the additional constraint that you
> first need to have a string argument to strdup() that's long enough to
> cause a suffiently large argument to be passed to malloc().
>
> One data point: On my Ubuntu system, malloc(SIZE_MAX) returns NULL for
> very large arguments (over about 23 GiB in my quick and dirty test).

I'm guessing that might be only be because of the overcommit_ratio
value; i.e that allowing a 23 GiB increment in the allocated address
space would bring the system over the currently configured overcommit
ratio.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: avoiding strdup()

<UCHHN.125446$TSTa.5399@fx47.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51973&group=comp.lang.c#51973

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx47.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: avoiding strdup()
Newsgroups: comp.lang.c
References: <us0brl$246bf$1@dont-email.me> <pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid> <usc845$10v6e$1@dont-email.me> <pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid> <ushea7$28prq$2@dont-email.me> <ushnkb$1rnlb$4@dont-email.me> <87r0gizzuo.fsf@nosuchdomain.example.com> <20240310101101.00001fd4@yahoo.com> <20240310100715.866@kylheku.com> <ifnHN.386274$vFZa.250421@fx13.iad> <usnb64$3n297$1@dont-email.me> <20240311185039.000066fc@yahoo.com> <87edcgzo7r.fsf@nosuchdomain.example.com>
Lines: 17
Message-ID: <UCHHN.125446$TSTa.5399@fx47.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Mon, 11 Mar 2024 17:58:12 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Mon, 11 Mar 2024 17:58:12 GMT
X-Received-Bytes: 1863
 by: Scott Lurndal - Mon, 11 Mar 2024 17:58 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>Michael S <already5chosen@yahoo.com> writes:
>[...]
>> Is there any chance at all that on typical Linux machine (i.e. the one
>> configured to overcommit virtual memory) strdup() returns NULL?
>> If it was malloc() I'd say - no chance. For strdup() I'm less sure.
>
>strdup() calls malloc(), so strdup() can return NULL if and only if
>malloc() can return NULL -- but with the additional constraint that you
>first need to have a string argument to strdup() that's long enough to
>cause a suffiently large argument to be passed to malloc().
>
>One data point: On my Ubuntu system, malloc(SIZE_MAX) returns NULL for
>very large arguments (over about 23 GiB in my quick and dirty test).

That may be due to resource limits (setrlimit/getrlimit/ulimit) on
the size of the address space.

Re: avoiding strdup()

<VKHHN.125447$TSTa.32477@fx47.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51974&group=comp.lang.c#51974

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx47.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: avoiding strdup()
Newsgroups: comp.lang.c
References: <us0brl$246bf$1@dont-email.me> <usc845$10v6e$1@dont-email.me> <pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid> <ushea7$28prq$2@dont-email.me> <ushnkb$1rnlb$4@dont-email.me> <87r0gizzuo.fsf@nosuchdomain.example.com> <20240310101101.00001fd4@yahoo.com> <20240310100715.866@kylheku.com> <ifnHN.386274$vFZa.250421@fx13.iad> <usnb64$3n297$1@dont-email.me> <20240311185039.000066fc@yahoo.com> <ERGHN.481215$PuZ9.417692@fx11.iad> <20240311193511.0000610f@yahoo.com>
Lines: 114
Message-ID: <VKHHN.125447$TSTa.32477@fx47.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Mon, 11 Mar 2024 18:06:45 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Mon, 11 Mar 2024 18:06:45 GMT
X-Received-Bytes: 6086
 by: Scott Lurndal - Mon, 11 Mar 2024 18:06 UTC

Michael S <already5chosen@yahoo.com> writes:
>On Mon, 11 Mar 2024 17:05:40 GMT
>scott@slp53.sl.home (Scott Lurndal) wrote:
>
>> Michael S <already5chosen@yahoo.com> writes:
>> >On Mon, 11 Mar 2024 16:23:32 +0000
>> >Malcolm McLean <malcolm.arthur.mclean@gmail.com> wrote:
>> >
>> >> On 10/03/2024 18:47, Scott Lurndal wrote:
>> >> > Kaz Kylheku <433-929-6894@kylheku.com> writes:
>> >> >> On 2024-03-10, Michael S <already5chosen@yahoo.com> wrote:
>> >> >>> On Sat, 09 Mar 2024 16:37:19 -0800
>> >> >>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> >> >>>> strdup() and strndup() are being added to the C23 standard.
>> >> >>>>
>> >> >>>
>> >> >>> What is justification?
>> >> >>
>> >> >> strdup is required by POSIX already and thus widely implemented.
>> >> >> Many programmers who are not into standards already assume it's
>> >> >> in C.
>> >> >>
>> >> >> For decades, portable programs have been doing things like this:
>> >> >>
>> >> >> #if HAVE_STRDUP
>> >> >> #define xstrdup(s) strdup(s)
>> >> >> #else
>> >> >> char *xstrdup(const char *); // own definition
>> >> >> #endif
>> >> >>
>> >> >>> What strdup() can do better, for any chosen value of better,
>> >> >>> than strlen()+malloc()+memcpy() ?
>> >> >>
>> >> >> Not take up space in every application for a common library
>> >> >> routine.
>> >> >
>> >> > It's a form of lazy programming. I've seen a lot of open source
>> >> > code that uses strdup without checking for failure and frequently
>> >> > "forgetting" to free the result.
>> >>
>> >> And it is probably more likely that machine with many gigabytes of
>> >> RAM will develop an electrical fault than that that call for a
>> >> short string will be the point where it runs out of memory.
>> >
>> >Is there any chance at all that on typical Linux machine (i.e. the
>> >one configured to overcommit virtual memory) strdup() returns NULL?
>> >If it was malloc() I'd say - no chance. For strdup() I'm less sure.
>> >
>>
>> An unanswerable question. But, consider that not all allocations
>> in an application use strdup as the only memory allocator (the
>> majority don't, and other allocations may be much larger), yet both
>> use the same pool of address space and host memory.
>>
>> Consider also that on unix and linux, there are a number of resource
>> limits intended to prevent a single application from consuming all of
>> memory, which a call to strdup may encounter even with plenty of RAM
>> available.
>>
>> Toy applications may not have an issue with strdup. Real
>> applications on the other hand might, and an unexpected SIGSEGV is
>> extremely user-unfriendly and could have catastrophic results.
>>
>
>
>According to my understanding, on Linux with overcommit enabled,
>typical behavior would be that allocation (of non-extravagant size,
>say, no more than 100 MB) always succeeds. OOM is called later, on
>access. It seems, that most commonly OOM does not hit application that
>is allocating right now. Much more likely that it will kill app that
>user opened hours ago, then put aside and then tried to use again.
>
>> And on the gripping hand, not testing for a potential catastrophic
>> failure condition, no matter how unlikely isn't the sign of a good
>> programmer.
>
>Some people would say that writing code (a handler for allocation
>returning NULL) that either can't be tested in principle or can be
>tested only in principle, but most certainly not tested in
>practice, isn't a sign of a good programmer.

1) It is certainly possible to test in practice (unit test, or random error-injection).
2) I've never heard anyone say that.

>Myself, I still tend to code this checks, but
>(1) my main targets are not Linux with overcommit, so the
>chance of allocation returning NULL could be estimated like "not going
>to happen" rather than "can't happen".
>(2) I am old full that like his unreasonable old habits

I consider software that can cause a SIGSEGV when run by
a customer to be broken. The programmer(s) should take
every reasonable precaution to ensure that doesn't happen.

If the OOM killer (in any system where overcommit is enabled)
must run, the system is by definition unstable.

>
>At least, I stopped checking return value of fclose() after being told,
>with facts, how stupid it is. So, may be, one day I'd convince myself to
>stop checking return value of malloc() as well.

An application that cares will fsync(2) the file descriptor before
closing it with close(2) and will check the fsync return value and
take appropriate action if it fails.

While I personally eschew fopen/fclose and their ilk due to
performance overhead generally, were I to use it for data which
is required to be valid, I'd always check the results of fflush
before closing with fclose().

It really depends on the application and the importance of the
data (ephemeral data, e.g. terminal output from ps(1), may not require the
same level of scrutiny as a database, for example).

Re: avoiding strdup()

<3OHHN.125448$TSTa.103211@fx47.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51975&group=comp.lang.c#51975

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.neodome.net!npeer.as286.net!npeer-ng0.as286.net!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx47.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: avoiding strdup()
Newsgroups: comp.lang.c
References: <us0brl$246bf$1@dont-email.me> <pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid> <usc845$10v6e$1@dont-email.me> <pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid> <ushea7$28prq$2@dont-email.me> <ushnkb$1rnlb$4@dont-email.me> <87r0gizzuo.fsf@nosuchdomain.example.com> <20240310101101.00001fd4@yahoo.com> <20240310100715.866@kylheku.com> <ifnHN.386274$vFZa.250421@fx13.iad> <usnb64$3n297$1@dont-email.me> <yMGHN.481214$PuZ9.381006@fx11.iad> <20240311104527.444@kylheku.com>
Lines: 36
Message-ID: <3OHHN.125448$TSTa.103211@fx47.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Mon, 11 Mar 2024 18:10:07 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Mon, 11 Mar 2024 18:10:07 GMT
X-Received-Bytes: 2683
 by: Scott Lurndal - Mon, 11 Mar 2024 18:10 UTC

Kaz Kylheku <433-929-6894@kylheku.com> writes:
>On 2024-03-11, Scott Lurndal <scott@slp53.sl.home> wrote:
>> Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>>>On 10/03/2024 18:47, Scott Lurndal wrote:
>>>> Kaz Kylheku <433-929-6894@kylheku.com> writes:
>>>>> Not take up space in every application for a common library routine.
>>>>
>>>> It's a form of lazy programming. I've seen a lot of open source
>>>> code that uses strdup without checking for failure and frequently
>>>> "forgetting" to free the result.
>>>
>>>And it is probably more likely that machine with many gigabytes of RAM
>>
>> Actually, your assumptions that:
>> 1) strdup is the only allocation function used by an application
>> 2) all strings are "short"
>
>Even if a string is long enough to need its own mmap request,
>that will still return valid memory that later fails to commit.

Production linux systems generally disable overcommit. Developing
applications that count on overcommit is a flawed idea.

>
>Under overcommit conditions, you will only reliably get null return out
>of a large strdup if you've exhausted your local address space
>(of which you have lots under 64 bits).

Under overcommit, your application will likely be killed by
the operating system OOM killer, or some other process
may be killed. That is unacceptable in a production environment.

The local address space is limited in unix and linux on a
per-process basis. (setrlimit/getrlimit). The administrator
sets system-wide limits, which can be overridden on a per
UID basis via PAM.

Re: avoiding strdup()

<87msr4aaio.fsf@nosuchdomain.example.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51976&group=comp.lang.c#51976

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: avoiding strdup()
Date: Mon, 11 Mar 2024 11:28:15 -0700
Organization: None to speak of
Lines: 38
Message-ID: <87msr4aaio.fsf@nosuchdomain.example.com>
References: <us0brl$246bf$1@dont-email.me>
<pan$4fc39$61bdfbef$3ca9a71a$af842694@invalid.invalid>
<87y1ayj6hs.fsf_-_@bsb.me.uk>
<pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid>
<usc845$10v6e$1@dont-email.me>
<pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid>
<ushea7$28prq$2@dont-email.me> <ushnkb$1rnlb$4@dont-email.me>
<87r0gizzuo.fsf@nosuchdomain.example.com>
<20240310101101.00001fd4@yahoo.com> <20240310100715.866@kylheku.com>
<ifnHN.386274$vFZa.250421@fx13.iad> <usnb64$3n297$1@dont-email.me>
<20240311185039.000066fc@yahoo.com>
<87edcgzo7r.fsf@nosuchdomain.example.com>
<20240311105508.215@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="803e1d91970c7135fb6b17cffb70db2d";
logging-data="3955985"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19tTX/QlP+O7eXH4NNww/Ma"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:/HPdn6Gk2miTXHUZKO8Sg6pURz8=
sha1:HSwnGDvBEwI9W1zndThYNaYhxO8=
 by: Keith Thompson - Mon, 11 Mar 2024 18:28 UTC

Kaz Kylheku <433-929-6894@kylheku.com> writes:
> On 2024-03-11, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> Michael S <already5chosen@yahoo.com> writes:
>> [...]
>>> Is there any chance at all that on typical Linux machine (i.e. the one
>>> configured to overcommit virtual memory) strdup() returns NULL?
>>> If it was malloc() I'd say - no chance. For strdup() I'm less sure.
>>
>> strdup() calls malloc(), so strdup() can return NULL if and only if
>> malloc() can return NULL -- but with the additional constraint that you
>> first need to have a string argument to strdup() that's long enough to
>> cause a suffiently large argument to be passed to malloc().
>>
>> One data point: On my Ubuntu system, malloc(SIZE_MAX) returns NULL for
>> very large arguments (over about 23 GiB in my quick and dirty test).
>
> I'm guessing that might be only be because of the overcommit_ratio
> value; i.e that allowing a 23 GiB increment in the allocated address
> space would bring the system over the currently configured overcommit
> ratio.

Good guess, but I don't think so.

$ cat /proc/sys/vm/overcommit_memory
0
$ cat /proc/sys/vm/overcommit_ratio
50

(These are the default values.) If I'm reading the proc(5) man page
correctly (which is questionable), 0 means "heuristic overcommit", and
overcommit_ratio is ignored unless the mode is set to 2.

I have 12 GB of physical memory.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: avoiding strdup()

<20240311202914.00005cab@yahoo.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51977&group=comp.lang.c#51977

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: already5chosen@yahoo.com (Michael S)
Newsgroups: comp.lang.c
Subject: Re: avoiding strdup()
Date: Mon, 11 Mar 2024 20:29:14 +0200
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <20240311202914.00005cab@yahoo.com>
References: <us0brl$246bf$1@dont-email.me>
<usc845$10v6e$1@dont-email.me>
<pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid>
<ushea7$28prq$2@dont-email.me>
<ushnkb$1rnlb$4@dont-email.me>
<87r0gizzuo.fsf@nosuchdomain.example.com>
<20240310101101.00001fd4@yahoo.com>
<20240310100715.866@kylheku.com>
<ifnHN.386274$vFZa.250421@fx13.iad>
<usnb64$3n297$1@dont-email.me>
<20240311185039.000066fc@yahoo.com>
<ERGHN.481215$PuZ9.417692@fx11.iad>
<20240311193511.0000610f@yahoo.com>
<VKHHN.125447$TSTa.32477@fx47.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="20135147cba2d202cd079ad5c3141fdd";
logging-data="3951092"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX197Kf723nDJq4GyrkyzrM94Xq0+zrPObSs="
Cancel-Lock: sha1:UaGS5adyRcDvwDviLNd/KiBqs6g=
X-Newsreader: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32)
 by: Michael S - Mon, 11 Mar 2024 18:29 UTC

>
> An application that cares will fsync(2) the file descriptor before
> closing it with close(2) and will check the fsync return value and
> take appropriate action if it fails.
>
> While I personally eschew fopen/fclose and their ilk due to
> performance overhead generally, were I to use it for data which
> is required to be valid, I'd always check the results of fflush
> before closing with fclose().

Last I looked at it, and it was several years ago, so can misremember,
fflush() is only slightly better, if at all better, than fclose(). It
also does not guarantee that my data propagated beyond filesystem write
cache.
For fsync() there are problems as well.
(1) - it is not part of C Standard.
(2) - even on systems where it is implemented, like Linux, BSD and
Mac, it is likely to not do the same things.
(3) - if done in UI thread, it's likely to negatively affect
responsiveness of UI. If not done in UI thread, it's too much of
error-prone code to write.

>
> It really depends on the application and the importance of the
> data (ephemeral data, e.g. terminal output from ps(1), may not
> require the same level of scrutiny as a database, for example).


devel / comp.lang.c / "White House to Developers: Using C or C++ Invites Cybersecurity Risks"

Pages:12345678910
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor