Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

RIP is irrelevant. Spoofing is futile. Your routes will be aggregated. -- Alex Yuriev


computers / comp.os.vms / Re: ChatGPT solved it for me, again...

SubjectAuthor
* ChatGPT solved it for me, again...Slo
+* Re: ChatGPT solved it for me, again...Arne Vajhøj
|+* Re: ChatGPT solved it for me, again...Steven Schweda
||`- Re: ChatGPT solved it for me, again...Arne Vajhøj
|+* Re: ChatGPT solved it for me, again...David Wade
||`* Re: ChatGPT solved it for me, again...Slo
|| +- Re: ChatGPT solved it for me, again...Slo
|| +- Re: ChatGPT solved it for me, again...Slo
|| `* Re: ChatGPT solved it for me, again...Johnny Billquist
||  +- Re: ChatGPT solved it for me, again...cao...@pitbulluk.org
||  `* Re: ChatGPT solved it for me, again...Steven Schweda
||   +- Re: ChatGPT solved it for me, again...Johnny Billquist
||   `- Re: ChatGPT solved it for me, again...gah4
|`* Re: ChatGPT solved it for me, again...Hans Bachner
| `* Re: ChatGPT solved it for me, again...Arne Vajhøj
|  +* Re: ChatGPT solved it for me, again...Slo
|  |+* Re: ChatGPT solved it for me, again...Simon Clubley
|  ||+* Re: ChatGPT solved it for me, again...Arne Vajhøj
|  |||`* Re: ChatGPT solved it for me, again...Simon Clubley
|  ||| +* Re: ChatGPT solved it for me, again...Arne Vajhøj
|  ||| |`* Re: ChatGPT solved it for me, again...Simon Clubley
|  ||| | +* Re: ChatGPT solved it for me, again...Arne Vajhøj
|  ||| | |+* Re: ChatGPT solved it for me, again...Slo
|  ||| | ||+* Re: ChatGPT solved it for me, again...Slo
|  ||| | |||`- Re: ChatGPT solved it for me, again...Arne Vajhøj
|  ||| | ||+- Re: ChatGPT solved it for me, again...Arne Vajhøj
|  ||| | ||`- Re: ChatGPT solved it for me, again...bill
|  ||| | |`* Re: ChatGPT solved it for me, again...Simon Clubley
|  ||| | | `- Re: ChatGPT solved it for me, again...Arne Vajhøj
|  ||| | +- Re: ChatGPT solved it for me, again...bill
|  ||| | `* Re: ChatGPT solved it for me, again...Johnny Billquist
|  ||| |  +* Re: ChatGPT solved it for me, again...Simon Clubley
|  ||| |  |`- Re: ChatGPT solved it for me, again...Johnny Billquist
|  ||| |  `* Re: ChatGPT solved it for me, again...bill
|  ||| |   +- Re: ChatGPT solved it for me, again...Arne Vajhøj
|  ||| |   `- Re: ChatGPT solved it for me, again...Dan Cross
|  ||| `* Re: ChatGPT solved it for me, again...Johnny Billquist
|  |||  `* Re: ChatGPT solved it for me, again...Arne Vajhøj
|  |||   `* Re: ChatGPT solved it for me, again...Simon Clubley
|  |||    `- Re: ChatGPT solved it for me, again...Arne Vajhøj
|  ||`- Re: ChatGPT solved it for me, again...Johnny Billquist
|  |+- Re: ChatGPT solved it for me, again...Arne Vajhøj
|  |`- Re: ChatGPT solved it for me, again...Single Stage to Orbit
|  `* Re: ChatGPT solved it for me, again...Single Stage to Orbit
|   `* Re: ChatGPT solved it for me, again...Stephen Hoffman
|    `- Re: ChatGPT solved it for me, again...Single Stage to Orbit
+* Re: ChatGPT solved it for me, again...Michael Kraemer @ home
|`* Re: ChatGPT solved it for me, again...Slo
| `* Re: ChatGPT solved it for me, again...Simon Clubley
|  `* Re: ChatGPT solved it for me, again...Slo
|   +* Re: ChatGPT solved it for me, again...Slo
|   |+* Re: ChatGPT solved it for me, again...Simon Clubley
|   ||`* Re: ChatGPT solved it for me, again...Slo
|   || `- Re: ChatGPT solved it for me, again...Simon Clubley
|   |`- Re: ChatGPT solved it for me, again...Johnny Billquist
|   +* Re: ChatGPT solved it for me, again...Robert A. Brooks
|   |+- Re: ChatGPT solved it for me, again...Slo
|   |+* Re: ChatGPT solved it for me, again...Johnny Billquist
|   ||`- Re: ChatGPT solved it for me, again...bill
|   |`- Re: ChatGPT solved it for me, again...bill
|   +- Re: ChatGPT solved it for me, again...bill
|   `* Re: ChatGPT solved it for me, again...Andy Burns
|    `* Re: ChatGPT solved it for me, again...Slo
|     `* Re: ChatGPT solved it for me, again...bill
|      +- Re: ChatGPT solved it for me, again...Slo
|      `- Re: ChatGPT solved it for me, again...gah4
+- Re: ChatGPT solved it for me, again...Simon Clubley
+- Re: ChatGPT solved it for me, again...Stephen Hoffman
`- Re: ChatGPT solved it for me, again...gah4

Pages:123
Re: ChatGPT solved it for me, again...

<k59lnsFtd0kU3@mid.individual.net>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=26710&group=comp.os.vms#26710

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: bill.gun...@gmail.com (bill)
Newsgroups: comp.os.vms
Subject: Re: ChatGPT solved it for me, again...
Date: Fri, 17 Feb 2023 10:44:59 -0500
Lines: 27
Message-ID: <k59lnsFtd0kU3@mid.individual.net>
References: <66d83417-1175-4bc0-a049-3df36e14fb5dn@googlegroups.com>
<tsh6vi$2lhib$1@dont-email.me> <k570fcF7jcU1@mid.individual.net>
<tsmnca$3e1n8$2@dont-email.me>
<a7db0d71-3fe6-4661-8688-3f8c184f0ae9n@googlegroups.com>
<tsnuug$3koj1$1@dont-email.me> <tsnvbu$3kqmj$2@dont-email.me>
<tso11b$3l0kq$1@dont-email.me> <tso1mo$3kqmi$1@dont-email.me>
<tso27i$3l597$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net KYAjpFqS+R+r0bzfMQum1gZY5qoYecC69tnhvrMDfUdkA9dMtn
Cancel-Lock: sha1:kjwK+8gBAI2/PjNQpWJjD/+DKlI=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.7.2
Content-Language: en-US
In-Reply-To: <tso27i$3l597$1@dont-email.me>
 by: bill - Fri, 17 Feb 2023 15:44 UTC

On 2/17/2023 9:16 AM, Simon Clubley wrote:
> On 2023-02-17, Arne Vajhøj <arne@vajhoej.dk> wrote:
>>
>> strcspn will stop when it reach the terminating null byte.
>>
>
> Are you sure about that ?
>
> https://linux.die.net/man/3/strcspn
>
> There's no mention of stopping at a null and no mention of what the
> return value is when the byte is not found within the string if it
> were to stop at a terminating null.

Then either the Linux manpage is deficient or the routine is broken.

From a BSD man:

The strcspn() function spans the initial part of the nul-terminated
string s as long as the characters from s do not occur in string
charset (it spans the complement of charset).

Or we have a problem of conflicting standards. :-)

bill

Re: ChatGPT solved it for me, again...

<k59ltvFtd0kU4@mid.individual.net>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=26711&group=comp.os.vms#26711

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: bill.gun...@gmail.com (bill)
Newsgroups: comp.os.vms
Subject: Re: ChatGPT solved it for me, again...
Date: Fri, 17 Feb 2023 10:48:14 -0500
Lines: 60
Message-ID: <k59ltvFtd0kU4@mid.individual.net>
References: <66d83417-1175-4bc0-a049-3df36e14fb5dn@googlegroups.com>
<tsh6vi$2lhib$1@dont-email.me> <k570fcF7jcU1@mid.individual.net>
<tsmnca$3e1n8$2@dont-email.me>
<a7db0d71-3fe6-4661-8688-3f8c184f0ae9n@googlegroups.com>
<tsnuug$3koj1$1@dont-email.me> <tsnvbu$3kqmj$2@dont-email.me>
<tso11b$3l0kq$1@dont-email.me> <tso1mo$3kqmi$1@dont-email.me>
<tso27i$3l597$1@dont-email.me> <tso2jt$3kqmi$2@dont-email.me>
<fe033036-3d0a-4c62-ab5d-186117533c0an@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net 7pZUjMysfsluZVnu1izjvA6ZL+y0qgxyiYqmEB3jhiVlvJcpln
Cancel-Lock: sha1:NfD5Du3hKrek7ZPcd+awz5s7UW0=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.7.2
Content-Language: en-US
In-Reply-To: <fe033036-3d0a-4c62-ab5d-186117533c0an@googlegroups.com>
 by: bill - Fri, 17 Feb 2023 15:48 UTC

On 2/17/2023 9:45 AM, Slo wrote:
> Me: But fgets() is not guaranteed to return a newline character. Can you improve the code?
> ==========================
> You're correct that fgets() may not return the newline character if the
> input buffer is filled before encountering a newline. Here's an updated
> version of the code that handles this case:
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <time.h>
> #include <string.h>
>
> int get_wattage(char *sys) {
> return (rand() % 20) * 50 + 200;
> }
>
> int main() {
> srand(time(NULL));
> char sys1[256], sys2[256];
> int watt1, watt2;
>
> printf("Utility to check power supply compatibility.\n");
> printf("Enter name of system #1: ");
> if (fgets(sys1, 256, stdin) == NULL) {
> perror("fgets failed");
> exit(1);
> }
> sys1[strcspn(sys1, "\n")] = '\0';
> if (sys1[0] == '\0') {
> fprintf(stderr, "Invalid input: system name cannot be empty\n");
> exit(1);
> }
> printf("Enter name of system #2: ");
> if (fgets(sys2, 256, stdin) == NULL) {
> perror("fgets failed");
> exit(1);
> }
> sys2[strcspn(sys2, "\n")] = '\0';
> if (sys2[0] == '\0') {
> fprintf(stderr, "Invalid input: system name cannot be empty\n");
> exit(1);
> }
> watt1 = get_wattage(sys1);
> watt2 = get_wattage(sys2);
>
> if (watt1 == watt2) {
> printf("%s and %s can use the same power supply (%d watt)\n", sys1, sys2, watt1);
> } else {
> printf("%s and %s cannot use the same power supply as they use %d and %d watt\n", sys1, sys2, watt1, watt2);
> }
> return 0;
> }
> ==========================
>

And people are already talking about trusting the code written by
the robot. :-) :-) :-)

bill

Re: ChatGPT solved it for me, again...

<tsogv3$3mmd3$1@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=26716&group=comp.os.vms#26716

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: club...@remove_me.eisner.decus.org-Earth.UFP (Simon Clubley)
Newsgroups: comp.os.vms
Subject: Re: ChatGPT solved it for me, again...
Date: Fri, 17 Feb 2023 18:27:47 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <tsogv3$3mmd3$1@dont-email.me>
References: <66d83417-1175-4bc0-a049-3df36e14fb5dn@googlegroups.com> <tsh6vi$2lhib$1@dont-email.me> <k570fcF7jcU1@mid.individual.net> <tsmnca$3e1n8$2@dont-email.me> <a7db0d71-3fe6-4661-8688-3f8c184f0ae9n@googlegroups.com> <tsnuug$3koj1$1@dont-email.me> <tsnvbu$3kqmj$2@dont-email.me> <tso11b$3l0kq$1@dont-email.me> <tso1mo$3kqmi$1@dont-email.me> <tso27i$3l597$1@dont-email.me> <tso2jt$3kqmi$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 17 Feb 2023 18:27:47 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="d4f1fe7df632104357f52e8adc4a0221";
logging-data="3889571"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Wml7+HSbv1M+Gg5EZ34OaXcg9Sb2quio="
User-Agent: slrn/0.9.8.1 (VMS/Multinet)
Cancel-Lock: sha1:Y3nmrs/zaLVenymrwd4+EDEZOZY=
 by: Simon Clubley - Fri, 17 Feb 2023 18:27 UTC

On 2023-02-17, Arne Vajhøj <arne@vajhoej.dk> wrote:
> On 2/17/2023 9:16 AM, Simon Clubley wrote:
>> On 2023-02-17, Arne Vajhøj <arne@vajhoej.dk> wrote:
>>>
>>> strcspn will stop when it reach the terminating null byte.
>>
>> Are you sure about that ?
>
> Yes.
>
>> https://linux.die.net/man/3/strcspn
>>
>> There's no mention of stopping at a null and no mention of what the
>> return value is when the byte is not found within the string if it
>> were to stop at a terminating null.
>
> "The strcspn() function returns the number of bytes in the initial
> segment of s which are not in the string reject."
>
> strcspn("abc\n", "\n") will return 3.
>
> strcspn("abc", "\n") will also return 3.
>
> That is what it says.
>

Then in that case I was wrong and I withdraw the original comment.

However, that man page is extremely misleading because when a routine
is setup to report that it didn't find something, it usually tells you
how it does that in the "RETURN VALUE" section of the documentation.

The version that Bill posted from BSD is better if not completely clear.

I had a look around to see if it was just me and it turns out it isn't:

https://stackoverflow.com/questions/32390478/what-is-the-return-value-of-strcspn-when-str1-does-not-contain-str2

The cplusplus.com reference pointed to there is far better than what is
in the man page.

Simon.

--
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Walking destinations on a map are further away than they appear.

Re: ChatGPT solved it for me, again...

<tsoim3$3msl1$1@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=26718&group=comp.os.vms#26718

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: arn...@vajhoej.dk (Arne Vajhøj)
Newsgroups: comp.os.vms
Subject: Re: ChatGPT solved it for me, again...
Date: Fri, 17 Feb 2023 13:57:00 -0500
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <tsoim3$3msl1$1@dont-email.me>
References: <66d83417-1175-4bc0-a049-3df36e14fb5dn@googlegroups.com>
<tsh6vi$2lhib$1@dont-email.me> <k570fcF7jcU1@mid.individual.net>
<tsmnca$3e1n8$2@dont-email.me>
<a7db0d71-3fe6-4661-8688-3f8c184f0ae9n@googlegroups.com>
<tsnuug$3koj1$1@dont-email.me> <tsnvbu$3kqmj$2@dont-email.me>
<tso11b$3l0kq$1@dont-email.me> <tso1mo$3kqmi$1@dont-email.me>
<tso27i$3l597$1@dont-email.me> <tso2jt$3kqmi$2@dont-email.me>
<tsogv3$3mmd3$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 17 Feb 2023 18:57:07 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="23993ab34d3e3c919cf74fffb0ff97ee";
logging-data="3895969"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+BA2Z93fnyITFmKunv2Cp7qWExOT9nqEc="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.7.2
Cancel-Lock: sha1:OSqpWDNHi+pnz/GpGcTOqTaEcAA=
In-Reply-To: <tsogv3$3mmd3$1@dont-email.me>
Content-Language: en-US
 by: Arne Vajhøj - Fri, 17 Feb 2023 18:57 UTC

On 2/17/2023 1:27 PM, Simon Clubley wrote:
> On 2023-02-17, Arne Vajhøj <arne@vajhoej.dk> wrote:
>> On 2/17/2023 9:16 AM, Simon Clubley wrote:
>>> On 2023-02-17, Arne Vajhøj <arne@vajhoej.dk> wrote:
>>>>
>>>> strcspn will stop when it reach the terminating null byte.
>>>
>>> Are you sure about that ?
>>
>> Yes.
>>
>>> https://linux.die.net/man/3/strcspn
>>>
>>> There's no mention of stopping at a null and no mention of what the
>>> return value is when the byte is not found within the string if it
>>> were to stop at a terminating null.
>>
>> "The strcspn() function returns the number of bytes in the initial
>> segment of s which are not in the string reject."
>>
>> strcspn("abc\n", "\n") will return 3.
>>
>> strcspn("abc", "\n") will also return 3.
>>
>> That is what it says.
>
> Then in that case I was wrong and I withdraw the original comment.
>
> However, that man page is extremely misleading because when a routine
> is setup to report that it didn't find something, it usually tells you
> how it does that in the "RETURN VALUE" section of the documentation.

The man page explains what it is returning.

In both examples above it detect 3 bytes in the start of s that
are not in reject, so it returns 3.

The "didn't find case" is not really a special case for
this function.

Arne

Re: ChatGPT solved it for me, again...

<d86ca6f6bdbf8ed857e0927f70992ae36fae407d.camel@munted.eu>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=26721&group=comp.os.vms#26721

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!palladium.buellnet!not-for-mail
From: alex.bu...@munted.eu (Single Stage to Orbit)
Newsgroups: comp.os.vms
Subject: Re: ChatGPT solved it for me, again...
Date: Fri, 17 Feb 2023 21:58:17 +0000
Organization: One very high maintenance cat
Message-ID: <d86ca6f6bdbf8ed857e0927f70992ae36fae407d.camel@munted.eu>
References: <66d83417-1175-4bc0-a049-3df36e14fb5dn@googlegroups.com>
<tsh6vi$2lhib$1@dont-email.me> <k570fcF7jcU1@mid.individual.net>
<tsmnca$3e1n8$2@dont-email.me>
<a7db0d71-3fe6-4661-8688-3f8c184f0ae9n@googlegroups.com>
Reply-To: alex.buell@munted.eu
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: solani.org;
logging-data="1061053"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Evolution 3.46.2
Cancel-Lock: sha1:k5nnnm4tIbpystf1kiJDLpL2UQI=
In-Reply-To: <a7db0d71-3fe6-4661-8688-3f8c184f0ae9n@googlegroups.com>
X-User-ID: eJwNyMEBwCAIA8CVoJJQxyEK+4/Q3vOw6DwZBAODMV0JOfMqns308TBXP3/XkfViV0C594X8loadRZoXT/UHeH4WzA==
 by: Single Stage to Orbi - Fri, 17 Feb 2023 21:58 UTC

On Fri, 2023-02-17 at 03:58 -0800, Slo wrote:
>    fgets(sys1, 256, stdin);
>    fgets(sys2, 256, stdin);

That's disgusting!! :-D
--
Tactical Nuclear Kittens

Re: ChatGPT solved it for me, again...

<7ea5c5069be05fe83434328f2628a1c12f703163.camel@munted.eu>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=26722&group=comp.os.vms#26722

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!rocksolid2!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!palladium.buellnet!not-for-mail
From: alex.bu...@munted.eu (Single Stage to Orbit)
Newsgroups: comp.os.vms
Subject: Re: ChatGPT solved it for me, again...
Date: Fri, 17 Feb 2023 21:56:32 +0000
Organization: One very high maintenance cat
Message-ID: <7ea5c5069be05fe83434328f2628a1c12f703163.camel@munted.eu>
References: <66d83417-1175-4bc0-a049-3df36e14fb5dn@googlegroups.com>
<tsh6vi$2lhib$1@dont-email.me> <k570fcF7jcU1@mid.individual.net>
<tsmnca$3e1n8$2@dont-email.me>
Reply-To: alex.buell@munted.eu
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: solani.org;
logging-data="1061053"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Evolution 3.46.2
Cancel-Lock: sha1:4sQDtAOYUZ+YsRJwaDOlvOw18KY=
X-User-ID: eJwFwYEBwCAIA7CXqlCc5yDQ/09YQosVdTwYTlFwybIZcZ9Jb/qm2XOiFKV9zRK9CHXt/GbOAjMxG0N1/nTQFpk=
In-Reply-To: <tsmnca$3e1n8$2@dont-email.me>
 by: Single Stage to Orbi - Fri, 17 Feb 2023 21:56 UTC

> >
> Yep.
>
> The ChatGPT answer was just wrong.
>
> I cannot provide any artificial intelligence, but
> here is something (I intended to post this earlier
> in this thread):
>
> $ run ArtificialStupidity
> Utility to check power supply compatibility.
> Enter name of system #1: 500au
> Enter name of system #2: XP1000
> 500au and XP1000 cannot use the same power supply as they use 200 and
> 850 watt

When will netnews ever gain the ability to handle unicode chars?!
There's a fair few emoiji I'd like to insert here (laughing crying face
for instance)
--
Tactical Nuclear Kittens

Re: ChatGPT solved it for me, again...

<tspf6r$3snpt$1@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=26724&group=comp.os.vms#26724

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: seaoh...@hoffmanlabs.invalid (Stephen Hoffman)
Newsgroups: comp.os.vms
Subject: Re: ChatGPT solved it for me, again...
Date: Fri, 17 Feb 2023 22:03:55 -0500
Organization: HoffmanLabs LLC
Lines: 15
Message-ID: <tspf6r$3snpt$1@dont-email.me>
References: <66d83417-1175-4bc0-a049-3df36e14fb5dn@googlegroups.com> <tsh6vi$2lhib$1@dont-email.me> <k570fcF7jcU1@mid.individual.net> <tsmnca$3e1n8$2@dont-email.me> <7ea5c5069be05fe83434328f2628a1c12f703163.camel@munted.eu>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: reader01.eternal-september.org; posting-host="fc16e9a899d3fe37a7d8ca43bdfd7a2c";
logging-data="4087613"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19jtyxg7gjejHt+F7w1S2fdTYC7/+rxSt0="
User-Agent: Unison/2.2
Cancel-Lock: sha1:vm4Mm4gEIsjb0PYhefMncrXjN8g=
 by: Stephen Hoffman - Sat, 18 Feb 2023 03:03 UTC

On 2023-02-17 21:56:32 +0000, Single Stage to Orbit said:

> When will netnews ever gain the ability to handle unicode chars?!

🤷🏼

> There's a fair few emoiji I'd like to insert here (laughing crying face
> for instance)

😂

--
Pure Personal Opinion | HoffmanLabs LLC

Re: ChatGPT solved it for me, again...

<796a4fab3d994e366dc5773e45ec7b2443606ab6.camel@munted.eu>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=26727&group=comp.os.vms#26727

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!palladium.buellnet!not-for-mail
From: alex.bu...@munted.eu (Single Stage to Orbit)
Newsgroups: comp.os.vms
Subject: Re: ChatGPT solved it for me, again...
Date: Sat, 18 Feb 2023 12:58:52 +0000
Organization: One very high maintenance cat
Message-ID: <796a4fab3d994e366dc5773e45ec7b2443606ab6.camel@munted.eu>
References: <66d83417-1175-4bc0-a049-3df36e14fb5dn@googlegroups.com>
<tsh6vi$2lhib$1@dont-email.me> <k570fcF7jcU1@mid.individual.net>
<tsmnca$3e1n8$2@dont-email.me>
<7ea5c5069be05fe83434328f2628a1c12f703163.camel@munted.eu>
<tspf6r$3snpt$1@dont-email.me>
Reply-To: alex.buell@munted.eu
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: solani.org;
logging-data="1087310"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Evolution 3.46.3
Cancel-Lock: sha1:jLSMZQDbdEEdW1wSquvTBzmhVDc=
X-User-ID: eJwNwokRACEIBLCW5FvYckSl/xLuJgmD4KQj4DE/i+JYn36JrJWqfsS73xZQjGTpigYuZ+15OuNxbYIp7vIBOnAUvQ==
In-Reply-To: <tspf6r$3snpt$1@dont-email.me>
 by: Single Stage to Orbi - Sat, 18 Feb 2023 12:58 UTC

On Fri, 2023-02-17 at 22:03 -0500, Stephen Hoffman wrote:
> > When will netnews ever gain the ability to handle unicode chars?!
>
> 🤷🏼
>
> > There's a fair few emoiji I'd like to insert here (laughing crying
> > face
> > for instance)
>
> 😂

Hmm, looks like my news client can't handle it then. 🤬
--
Tactical Nuclear Kittens

Re: ChatGPT solved it for me, again...

<tsvgmb$aab$1@news.misty.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=26809&group=comp.os.vms#26809

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!.POSTED.185.159.157.200!not-for-mail
From: bqt...@softjar.se (Johnny Billquist)
Newsgroups: comp.os.vms
Subject: Re: ChatGPT solved it for me, again...
Date: Mon, 20 Feb 2023 11:06:03 +0100
Organization: MGT Consulting
Message-ID: <tsvgmb$aab$1@news.misty.com>
References: <66d83417-1175-4bc0-a049-3df36e14fb5dn@googlegroups.com>
<tsh6vi$2lhib$1@dont-email.me> <k570fcF7jcU1@mid.individual.net>
<tsmnca$3e1n8$2@dont-email.me>
<a7db0d71-3fe6-4661-8688-3f8c184f0ae9n@googlegroups.com>
<tsnuug$3koj1$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 20 Feb 2023 10:06:03 -0000 (UTC)
Injection-Info: news.misty.com; posting-host="185.159.157.200";
logging-data="10571"; mail-complaints-to="abuse@misty.com"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.8.0
Content-Language: en-US
In-Reply-To: <tsnuug$3koj1$1@dont-email.me>
 by: Johnny Billquist - Mon, 20 Feb 2023 10:06 UTC

On 2023-02-17 14:20, Simon Clubley wrote:
> On 2023-02-17, Slo <slovuj@gmail.com> wrote:
>> Sorry Arne, I don't trust your coding skills and an ancient language :-)
>
> That ancient language is more secure than C. :-)
>
>> Me: Convert this code to C
>> ============================
>> #include <stdio.h>
>> #include <stdlib.h>
>> #include <string.h>
>> #include <time.h>
>> int get_wattage(char *sys) {
>> return (rand() % 20) * 50 + 200;
>> }
>> int main() {
>> char sys1[256], sys2[256];
>> int watt1, watt2;
>> srand(time(NULL));
>> printf("Utility to check power supply compatibility.\n");
>> printf("Enter name of system #1: ");
>> fgets(sys1, 256, stdin);
>> printf("Enter name of system #2: ");
>> fgets(sys2, 256, stdin);
>> sys1[strcspn(sys1, "\n")] = '\0';
>> sys2[strcspn(sys2, "\n")] = '\0';
>
> OUCH! OUCH! OUCH!!!!!
>
> fgets() is not guaranteed to return a newline character.

True. If you have an eof, you (obviously) don't have a newline, nor do
you get it if there are "too many" characters input.

> Here's an online man page that confirms this:
>
> https://linux.die.net/man/3/fgets
>
> I hope people using this technology with "real" code understand and
> recognise this kind of thing...

Well, the code was actually "safe". It just replaced the first newline
with a NUL, if found. Otherwise it does nothing.
So I don't really see what point you were trying to make here.

Johnny

Re: ChatGPT solved it for me, again...

<tsvgqr$aab$2@news.misty.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=26810&group=comp.os.vms#26810

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!.POSTED.185.159.157.200!not-for-mail
From: bqt...@softjar.se (Johnny Billquist)
Newsgroups: comp.os.vms
Subject: Re: ChatGPT solved it for me, again...
Date: Mon, 20 Feb 2023 11:08:27 +0100
Organization: MGT Consulting
Message-ID: <tsvgqr$aab$2@news.misty.com>
References: <66d83417-1175-4bc0-a049-3df36e14fb5dn@googlegroups.com>
<tsh6vi$2lhib$1@dont-email.me> <k570fcF7jcU1@mid.individual.net>
<tsmnca$3e1n8$2@dont-email.me>
<a7db0d71-3fe6-4661-8688-3f8c184f0ae9n@googlegroups.com>
<tsnuug$3koj1$1@dont-email.me> <tsnvbu$3kqmj$2@dont-email.me>
<tso11b$3l0kq$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 20 Feb 2023 10:08:27 -0000 (UTC)
Injection-Info: news.misty.com; posting-host="185.159.157.200";
logging-data="10571"; mail-complaints-to="abuse@misty.com"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.8.0
Content-Language: en-US
In-Reply-To: <tso11b$3l0kq$1@dont-email.me>
 by: Johnny Billquist - Mon, 20 Feb 2023 10:08 UTC

On 2023-02-17 14:55, Simon Clubley wrote:
> On 2023-02-17, Arne Vajhøj <arne@vajhoej.dk> wrote:
>> On 2/17/2023 8:20 AM, Simon Clubley wrote:
>>> On 2023-02-17, Slo <slovuj@gmail.com> wrote:
>>>> Sorry Arne, I don't trust your coding skills and an ancient language :-)
>>>
>>> That ancient language is more secure than C. :-)
>>>
>>>> Me: Convert this code to C
>>>> ============================
>>>> #include <stdio.h>
>>>> #include <stdlib.h>
>>>> #include <string.h>
>>>> #include <time.h>
>>>> int get_wattage(char *sys) {
>>>> return (rand() % 20) * 50 + 200;
>>>> }
>>>> int main() {
>>>> char sys1[256], sys2[256];
>>>> int watt1, watt2;
>>>> srand(time(NULL));
>>>> printf("Utility to check power supply compatibility.\n");
>>>> printf("Enter name of system #1: ");
>>>> fgets(sys1, 256, stdin);
>>>> printf("Enter name of system #2: ");
>>>> fgets(sys2, 256, stdin);
>>>> sys1[strcspn(sys1, "\n")] = '\0';
>>>> sys2[strcspn(sys2, "\n")] = '\0';
>>>
>>> OUCH! OUCH! OUCH!!!!!
>>>
>>> fgets() is not guaranteed to return a newline character.
>>
>> And?
>>
>
> Take a closer look Arne.
>
> That code will continue searching memory for a byte with the value of
> a newline character and will then modify the first such byte it finds.
>
> In other words, an out of bounds write vulnerability that may be
> exploitable in some circumstances when the code is part of a larger
> program.
>
> Even worse, the generated code _appears_ to work ok for normal inputs.

No. You are incorrect. fgets() will put into the buffer up to n-1
characters, and *always* put a NUL in at the end.
strcspn() will search the string for a specific character, and return
the index for that character if found, or the index to the NUL character
that terminates the string, if character is not found. It will never
search beyond the string read by fgets().

Johnny

Re: ChatGPT solved it for me, again...

<tsvgss$aab$3@news.misty.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=26811&group=comp.os.vms#26811

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!.POSTED.185.159.157.200!not-for-mail
From: bqt...@softjar.se (Johnny Billquist)
Newsgroups: comp.os.vms
Subject: Re: ChatGPT solved it for me, again...
Date: Mon, 20 Feb 2023 11:09:32 +0100
Organization: MGT Consulting
Message-ID: <tsvgss$aab$3@news.misty.com>
References: <66d83417-1175-4bc0-a049-3df36e14fb5dn@googlegroups.com>
<tsh6vi$2lhib$1@dont-email.me> <k570fcF7jcU1@mid.individual.net>
<tsmnca$3e1n8$2@dont-email.me>
<a7db0d71-3fe6-4661-8688-3f8c184f0ae9n@googlegroups.com>
<tsnuug$3koj1$1@dont-email.me> <tsnvbu$3kqmj$2@dont-email.me>
<tso11b$3l0kq$1@dont-email.me> <tso1mo$3kqmi$1@dont-email.me>
<tso27i$3l597$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 20 Feb 2023 10:09:32 -0000 (UTC)
Injection-Info: news.misty.com; posting-host="185.159.157.200";
logging-data="10571"; mail-complaints-to="abuse@misty.com"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.8.0
Content-Language: en-US
In-Reply-To: <tso27i$3l597$1@dont-email.me>
 by: Johnny Billquist - Mon, 20 Feb 2023 10:09 UTC

On 2023-02-17 15:16, Simon Clubley wrote:
> On 2023-02-17, Arne Vajhøj <arne@vajhoej.dk> wrote:
>>
>> strcspn will stop when it reach the terminating null byte.
>>
>
> Are you sure about that ?
>
> https://linux.die.net/man/3/strcspn
>
> There's no mention of stopping at a null and no mention of what the
> return value is when the byte is not found within the string if it
> were to stop at a terminating null.

Quoting the man-page I have locally:

The strcspn() function spans the initial part of the null-terminated
string s as long as the characters from s do not occur in the null-
terminated string charset (it spans the complement of charset).
In other
words, it computes the string array index of the first character of s
which is also in charset, else the index of the first null character.

Johnny

Re: ChatGPT solved it for me, again...

<tsvre1$p5pf$1@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=26819&group=comp.os.vms#26819

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: club...@remove_me.eisner.decus.org-Earth.UFP (Simon Clubley)
Newsgroups: comp.os.vms
Subject: Re: ChatGPT solved it for me, again...
Date: Mon, 20 Feb 2023 13:09:21 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <tsvre1$p5pf$1@dont-email.me>
References: <66d83417-1175-4bc0-a049-3df36e14fb5dn@googlegroups.com> <tsh6vi$2lhib$1@dont-email.me> <k570fcF7jcU1@mid.individual.net> <tsmnca$3e1n8$2@dont-email.me> <a7db0d71-3fe6-4661-8688-3f8c184f0ae9n@googlegroups.com> <tsnuug$3koj1$1@dont-email.me> <tsnvbu$3kqmj$2@dont-email.me> <tso11b$3l0kq$1@dont-email.me> <tso1mo$3kqmi$1@dont-email.me> <tso27i$3l597$1@dont-email.me> <tsvgss$aab$3@news.misty.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 20 Feb 2023 13:09:21 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="db6c396720924658116336f4c4ee1e05";
logging-data="825135"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/eHSOPAhUps2oO2625QXvMUlEq86v3Dc0="
User-Agent: slrn/0.9.8.1 (VMS/Multinet)
Cancel-Lock: sha1:8cLVTkNs1gfg3gH/ShQ2fH/NCs8=
 by: Simon Clubley - Mon, 20 Feb 2023 13:09 UTC

On 2023-02-20, Johnny Billquist <bqt@softjar.se> wrote:
> On 2023-02-17 15:16, Simon Clubley wrote:
>> On 2023-02-17, Arne Vajhøj <arne@vajhoej.dk> wrote:
>>>
>>> strcspn will stop when it reach the terminating null byte.
>>>
>>
>> Are you sure about that ?
>>
>> https://linux.die.net/man/3/strcspn
>>
>> There's no mention of stopping at a null and no mention of what the
>> return value is when the byte is not found within the string if it
>> were to stop at a terminating null.
>
> Quoting the man-page I have locally:
>
> The strcspn() function spans the initial part of the null-terminated
> string s as long as the characters from s do not occur in the null-
> terminated string charset (it spans the complement of charset).
> In other
> words, it computes the string array index of the first character of s
> which is also in charset, else the index of the first null character.
>
>

BSD ?

That's what the Linux version should say. :-(

The way the Linux version is written, it came across as another gets()
style function, and given that someone at some time thought it was a
good idea to add gets() to the C RTL...

Simon.

--
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Walking destinations on a map are further away than they appear.

Re: ChatGPT solved it for me, again...

<k5hc43Ftd0kU6@mid.individual.net>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=26822&group=comp.os.vms#26822

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: bill.gun...@gmail.com (bill)
Newsgroups: comp.os.vms
Subject: Re: ChatGPT solved it for me, again...
Date: Mon, 20 Feb 2023 08:49:56 -0500
Lines: 32
Message-ID: <k5hc43Ftd0kU6@mid.individual.net>
References: <66d83417-1175-4bc0-a049-3df36e14fb5dn@googlegroups.com>
<tsh6vi$2lhib$1@dont-email.me> <k570fcF7jcU1@mid.individual.net>
<tsmnca$3e1n8$2@dont-email.me>
<a7db0d71-3fe6-4661-8688-3f8c184f0ae9n@googlegroups.com>
<tsnuug$3koj1$1@dont-email.me> <tsnvbu$3kqmj$2@dont-email.me>
<tso11b$3l0kq$1@dont-email.me> <tso1mo$3kqmi$1@dont-email.me>
<tso27i$3l597$1@dont-email.me> <tsvgss$aab$3@news.misty.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net b3KAGsB4SxqR58hfewUtCgoPttB2hg/AYEoTm/cSWW397Ikex8
Cancel-Lock: sha1:IMahMBPXzjDaEkKutvepsojdGP4=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.7.2
Content-Language: en-US
In-Reply-To: <tsvgss$aab$3@news.misty.com>
 by: bill - Mon, 20 Feb 2023 13:49 UTC

On 2/20/2023 5:09 AM, Johnny Billquist wrote:
> On 2023-02-17 15:16, Simon Clubley wrote:
>> On 2023-02-17, Arne Vajhøj <arne@vajhoej.dk> wrote:
>>>
>>> strcspn will stop when it reach the terminating null byte.
>>>
>>
>> Are you sure about that ?
>>
>> https://linux.die.net/man/3/strcspn
>>
>> There's no mention of stopping at a null and no mention of what the
>> return value is when the byte is not found within the string if it
>> were to stop at a terminating null.
>
> Quoting the man-page I have locally:
>
>      The strcspn() function spans the initial part of the null-terminated
>      string s as long as the characters from s do not occur in the null-
>      terminated string charset (it spans the complement of charset). In
> other
>      words, it computes the string array index of the first character of s
>      which is also in charset, else the index of the first null character.
>

Is yours from Linux? Seems the Linux and BSD man pages are quite
different. Have to wonder if this is a documentation problem or
if Linux has a broken implementation of strcspn().

bill

Re: ChatGPT solved it for me, again...

<tsvudl$pfmf$1@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=26823&group=comp.os.vms#26823

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: arn...@vajhoej.dk (Arne Vajhøj)
Newsgroups: comp.os.vms
Subject: Re: ChatGPT solved it for me, again...
Date: Mon, 20 Feb 2023 09:00:21 -0500
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <tsvudl$pfmf$1@dont-email.me>
References: <66d83417-1175-4bc0-a049-3df36e14fb5dn@googlegroups.com>
<tsh6vi$2lhib$1@dont-email.me> <k570fcF7jcU1@mid.individual.net>
<tsmnca$3e1n8$2@dont-email.me>
<a7db0d71-3fe6-4661-8688-3f8c184f0ae9n@googlegroups.com>
<tsnuug$3koj1$1@dont-email.me> <tsnvbu$3kqmj$2@dont-email.me>
<tso11b$3l0kq$1@dont-email.me> <tso1mo$3kqmi$1@dont-email.me>
<tso27i$3l597$1@dont-email.me> <tsvgss$aab$3@news.misty.com>
<k5hc43Ftd0kU6@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 20 Feb 2023 14:00:21 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="aec734a1a4ec84c20e327f56713966ee";
logging-data="835279"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19FmSoxnFyxxOr0mMajZub4LaOOUOEen/c="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:7mw1Nlx4Wl1SlKje5R+ckoohmyI=
Content-Language: en-US
In-Reply-To: <k5hc43Ftd0kU6@mid.individual.net>
 by: Arne Vajhøj - Mon, 20 Feb 2023 14:00 UTC

On 2/20/2023 8:49 AM, bill wrote:
> On 2/20/2023 5:09 AM, Johnny Billquist wrote:
>> On 2023-02-17 15:16, Simon Clubley wrote:
>>> On 2023-02-17, Arne Vajhøj <arne@vajhoej.dk> wrote:
>>>> strcspn will stop when it reach the terminating null byte.
>>>
>>> Are you sure about that ?
>>>
>>> https://linux.die.net/man/3/strcspn
>>>
>>> There's no mention of stopping at a null and no mention of what the
>>> return value is when the byte is not found within the string if it
>>> were to stop at a terminating null.
>>
>> Quoting the man-page I have locally:
>>
>>       The strcspn() function spans the initial part of the
>> null-terminated
>>       string s as long as the characters from s do not occur in the null-
>>       terminated string charset (it spans the complement of charset).
>> In other
>>       words, it computes the string array index of the first character
>> of s
>>       which is also in charset, else the index of the first null
>> character.
>
> Is yours from Linux?  Seems the Linux and BSD man pages are quite
> different.  Have to wonder if this is a documentation problem or
> if Linux has a broken implementation of strcspn().

Strictly speaking Linux does not have strcspn - the
C library has.

But glibc strcspn works exactly as it should.

https://github.com/zerovm/glibc/blob/master/string/strcspn.c

Actually I think the code is more readable than
the BSD implementation:

https://android.googlesource.com/platform/bionic/+/ics-mr0/libc/string/strcspn.c

YMMV

Disclaimer: neither of the links are master for glibc or OpenBSD
source code, but I assume the comments about origin are true.

Arne

Re: ChatGPT solved it for me, again...

<tsvvj4$11$1@reader2.panix.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=26825&group=comp.os.vms#26825

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cro...@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.os.vms
Subject: Re: ChatGPT solved it for me, again...
Date: Mon, 20 Feb 2023 14:20:20 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <tsvvj4$11$1@reader2.panix.com>
References: <66d83417-1175-4bc0-a049-3df36e14fb5dn@googlegroups.com> <tso27i$3l597$1@dont-email.me> <tsvgss$aab$3@news.misty.com> <k5hc43Ftd0kU6@mid.individual.net>
Injection-Date: Mon, 20 Feb 2023 14:20:20 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
logging-data="33"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
 by: Dan Cross - Mon, 20 Feb 2023 14:20 UTC

In article <k5hc43Ftd0kU6@mid.individual.net>,
bill <bill.gunshannon@gmail.com> wrote:
>On 2/20/2023 5:09 AM, Johnny Billquist wrote:
>> On 2023-02-17 15:16, Simon Clubley wrote:
>>> On 2023-02-17, Arne Vajhøj <arne@vajhoej.dk> wrote:
>>>>
>>>> strcspn will stop when it reach the terminating null byte.
>>>>
>>>
>>> Are you sure about that ?
>>>
>>> https://linux.die.net/man/3/strcspn
>>>
>>> There's no mention of stopping at a null and no mention of what the
>>> return value is when the byte is not found within the string if it
>>> were to stop at a terminating null.
>>
>> Quoting the man-page I have locally:
>>
>> The strcspn() function spans the initial part of the null-terminated
>> string s as long as the characters from s do not occur in the null-
>> terminated string charset (it spans the complement of charset). In
>> other words, it computes the string array index of the first character
>> of s which is also in charset, else the index of the first null character.
>
>Is yours from Linux? Seems the Linux and BSD man pages are quite
>different. Have to wonder if this is a documentation problem or
>if Linux has a broken implementation of strcspn().

Broken in what way? This seems entirely consistent with the
definition in the BSD man page. The OpenBSD 7.2 man page even
gives an example surprisingly close to what was posted earlier:

--->BEGIN<---
EXAMPLES
[snip...]

The following removes the first (if any) newline character from string
line. This is useful for trimming the newline after a fgets(3) call.

char line[BUFSIZ];

if (fgets(line, sizeof(line), fp) != NULL)
line[strcspn(line, "\n")] = '\0';
--->END<---

From the C11 standard, section 7.24.5.3:

"size_t strcspn(const char *s1, const char *s2);

The strcspn function computes the length of the maximum
initial segment of the string pointed to by s1 which
consists entirely of characters not from the string
pointed to by s2.

Returns
The strcspn function returns the length of the segment."

Note the use of the term "string", which is defined as used here
in section 7.1.1:

"A string is a contiguous sequence of characters terminated
by and including the first null character."

The idea that `strcspn` would return the index of the
terminating NUL character for its first argument, should the
string it points to not contain any non-NUL characters from
the second argument, follows from these two definitions.
Since both strings are considered to contain their terminating
NUL characters, then that would necessarily match if nothing
else did.

- Dan C.

Re: ChatGPT solved it for me, again...

<tt014o$pfmg$4@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=26830&group=comp.os.vms#26830

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: arn...@vajhoej.dk (Arne Vajhøj)
Newsgroups: comp.os.vms
Subject: Re: ChatGPT solved it for me, again...
Date: Mon, 20 Feb 2023 09:46:47 -0500
Organization: A noiseless patient Spider
Lines: 99
Message-ID: <tt014o$pfmg$4@dont-email.me>
References: <66d83417-1175-4bc0-a049-3df36e14fb5dn@googlegroups.com>
<tsh6vi$2lhib$1@dont-email.me> <k570fcF7jcU1@mid.individual.net>
<tsmnca$3e1n8$2@dont-email.me>
<a7db0d71-3fe6-4661-8688-3f8c184f0ae9n@googlegroups.com>
<tsnuug$3koj1$1@dont-email.me> <tsnvbu$3kqmj$2@dont-email.me>
<tso11b$3l0kq$1@dont-email.me> <tsvgqr$aab$2@news.misty.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 20 Feb 2023 14:46:48 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="aec734a1a4ec84c20e327f56713966ee";
logging-data="835280"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/v8WEWJMiwYYHerb6nRZ28nXETKRT8aG4="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:eBpdnovrnFSg2NQo5NUoPcKsN5o=
In-Reply-To: <tsvgqr$aab$2@news.misty.com>
Content-Language: en-US
 by: Arne Vajhøj - Mon, 20 Feb 2023 14:46 UTC

On 2/20/2023 5:08 AM, Johnny Billquist wrote:
> On 2023-02-17 14:55, Simon Clubley wrote:
>> On 2023-02-17, Arne Vajhøj <arne@vajhoej.dk> wrote:
>>> On 2/17/2023 8:20 AM, Simon Clubley wrote:
>>>> On 2023-02-17, Slo <slovuj@gmail.com> wrote:
>>>>>       fgets(sys1, 256, stdin);
>>>>>       printf("Enter name of system #2: ");
>>>>>       fgets(sys2, 256, stdin);
>>>>>       sys1[strcspn(sys1, "\n")] = '\0';
>>>>>       sys2[strcspn(sys2, "\n")] = '\0';
>>>>
>>>> OUCH! OUCH! OUCH!!!!!
>>>>
>>>> fgets() is not guaranteed to return a newline character.

>> That code will continue searching memory for a byte with the value of
>> a newline character and will then modify the first such byte it finds.
>>
>> In other words, an out of bounds write vulnerability that may be
>> exploitable in some circumstances when the code is part of a larger
>> program.
>>
>> Even worse, the generated code _appears_ to work ok for normal inputs.
>
> No. You are incorrect. fgets() will put into the buffer up to n-1
> characters, and *always* put a NUL in at the end.
> strcspn() will search the string for a specific character, and return
> the index for that character if found, or the index to the NUL character
> that terminates the string, if character is not found. It will never
> search beyond the string read by fgets().

As I think everybody has agreed by now then the code
is safe.

I still stand by my original assessment that I would not
have used strcspn for this. It seems weird to me to
search through the entire string in a way that can handle
multiple stop characters when one knows that there is
only one stop character and really are only interested
in the last char in the string.

Also note that even though in all practical cases
the Pascal and C code will act identical, then it is
possible to create a case where they do not on VMS.

$ type p.pas
program p(input,output);

type
pstr = varying [255] of char;

var
line : pstr;

begin
readln(line);
writeln(line.length:1);
end.
$ pas p
$ link p
$ type c.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{ char line[256];
fgets(line, 256, stdin);
line[strcspn(line, "\n")] = '\0';
printf("%d\n", strlen(line));
return 0;
} $ cc c
$ link c
$ run p
ABC
3 $
$ run c
ABC
3 $
$ define/user sys$input z.txt
$ run p
7 $ define/user sys$input z.txt
$ run c
3

The VMS knowledgeable has of course already guessed
the reason - the file z.txt is RFM:VAR and contains
a line with newline in.

I do not blame ChatGPT for not thinking about that. This
is a very special case.

Arne

Re: ChatGPT solved it for me, again...

<tt2gnq$155u9$1@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=26879&group=comp.os.vms#26879

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: club...@remove_me.eisner.decus.org-Earth.UFP (Simon Clubley)
Newsgroups: comp.os.vms
Subject: Re: ChatGPT solved it for me, again...
Date: Tue, 21 Feb 2023 13:25:14 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <tt2gnq$155u9$1@dont-email.me>
References: <66d83417-1175-4bc0-a049-3df36e14fb5dn@googlegroups.com> <tsh6vi$2lhib$1@dont-email.me> <k570fcF7jcU1@mid.individual.net> <tsmnca$3e1n8$2@dont-email.me> <a7db0d71-3fe6-4661-8688-3f8c184f0ae9n@googlegroups.com> <tsnuug$3koj1$1@dont-email.me> <tsnvbu$3kqmj$2@dont-email.me> <tso11b$3l0kq$1@dont-email.me> <tsvgqr$aab$2@news.misty.com> <tt014o$pfmg$4@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 21 Feb 2023 13:25:14 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="43e2f68a7a5cb96c4998fc882b25ea97";
logging-data="1218505"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18lOFEHpVXy3hEps8ekD73Ep54fy9sblLk="
User-Agent: slrn/0.9.8.1 (VMS/Multinet)
Cancel-Lock: sha1:QoZSKlrJBSkTQ5DP6ngWYpJN3qU=
 by: Simon Clubley - Tue, 21 Feb 2023 13:25 UTC

On 2023-02-20, Arne Vajhøj <arne@vajhoej.dk> wrote:
>
> As I think everybody has agreed by now then the code
> is safe.
>

Yes. :-)

> I still stand by my original assessment that I would not
> have used strcspn for this. It seems weird to me to
> search through the entire string in a way that can handle
> multiple stop characters when one knows that there is
> only one stop character and really are only interested
> in the last char in the string.
>

This is exactly how I normally do it - look at the last character
only and strip that if needed.

Of course, strlen() still has to search through the string before
it knows the length of it, so you don't save as much time as you
might expect.

>
> I do not blame ChatGPT for not thinking about that. This
> is a very special case.
>

ChatGPT not thinking about some things is how some people have been
able to trick it into doing certain things. :-)

Simon.

--
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Walking destinations on a map are further away than they appear.

Re: ChatGPT solved it for me, again...

<tt35ij$17a49$2@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=26885&group=comp.os.vms#26885

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: arn...@vajhoej.dk (Arne Vajhøj)
Newsgroups: comp.os.vms
Subject: Re: ChatGPT solved it for me, again...
Date: Tue, 21 Feb 2023 14:20:50 -0500
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <tt35ij$17a49$2@dont-email.me>
References: <66d83417-1175-4bc0-a049-3df36e14fb5dn@googlegroups.com>
<tsh6vi$2lhib$1@dont-email.me> <k570fcF7jcU1@mid.individual.net>
<tsmnca$3e1n8$2@dont-email.me>
<a7db0d71-3fe6-4661-8688-3f8c184f0ae9n@googlegroups.com>
<tsnuug$3koj1$1@dont-email.me> <tsnvbu$3kqmj$2@dont-email.me>
<tso11b$3l0kq$1@dont-email.me> <tsvgqr$aab$2@news.misty.com>
<tt014o$pfmg$4@dont-email.me> <tt2gnq$155u9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 21 Feb 2023 19:20:51 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="016eb8614956e1503a3727fc6bd0ac52";
logging-data="1288329"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ioZiFjilyFDMcoSzj//cv1Sp6tCrS3OI="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:8aDcboZexFTTk336Rah8v2H9WTQ=
Content-Language: en-US
In-Reply-To: <tt2gnq$155u9$1@dont-email.me>
 by: Arne Vajhøj - Tue, 21 Feb 2023 19:20 UTC

On 2/21/2023 8:25 AM, Simon Clubley wrote:
> On 2023-02-20, Arne Vajhøj <arne@vajhoej.dk> wrote:
>> I still stand by my original assessment that I would not
>> have used strcspn for this. It seems weird to me to
>> search through the entire string in a way that can handle
>> multiple stop characters when one knows that there is
>> only one stop character and really are only interested
>> in the last char in the string.
>>
>
> This is exactly how I normally do it - look at the last character
> only and strip that if needed.
>
> Of course, strlen() still has to search through the string before
> it knows the length of it, so you don't save as much time as you
> might expect.

Yes - strlen will involve some sort of loop.

But strcspn will involve a loop inside a loop.
Although the loop over the reject set will
be very short in this case.

glibc use while with strchr inside.

BSD use for with a do while inside.

(links posted previously)

Arne

Re: ChatGPT solved it for me, again...

<tt3l7d$9r6$1@news.misty.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=26900&group=comp.os.vms#26900

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!.POSTED.80-218-16-84.dclient.hispeed.ch!not-for-mail
From: bqt...@softjar.se (Johnny Billquist)
Newsgroups: comp.os.vms
Subject: Re: ChatGPT solved it for me, again...
Date: Wed, 22 Feb 2023 00:47:54 +0100
Organization: MGT Consulting
Message-ID: <tt3l7d$9r6$1@news.misty.com>
References: <66d83417-1175-4bc0-a049-3df36e14fb5dn@googlegroups.com>
<tsh6vi$2lhib$1@dont-email.me> <k570fcF7jcU1@mid.individual.net>
<tsmnca$3e1n8$2@dont-email.me>
<a7db0d71-3fe6-4661-8688-3f8c184f0ae9n@googlegroups.com>
<tsnuug$3koj1$1@dont-email.me> <tsnvbu$3kqmj$2@dont-email.me>
<tso11b$3l0kq$1@dont-email.me> <tso1mo$3kqmi$1@dont-email.me>
<tso27i$3l597$1@dont-email.me> <tsvgss$aab$3@news.misty.com>
<tsvre1$p5pf$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 21 Feb 2023 23:47:57 -0000 (UTC)
Injection-Info: news.misty.com; posting-host="80-218-16-84.dclient.hispeed.ch:80.218.16.84";
logging-data="10086"; mail-complaints-to="abuse@misty.com"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.8.0
Content-Language: en-US
In-Reply-To: <tsvre1$p5pf$1@dont-email.me>
 by: Johnny Billquist - Tue, 21 Feb 2023 23:47 UTC

On 2023-02-20 14:09, Simon Clubley wrote:
> On 2023-02-20, Johnny Billquist <bqt@softjar.se> wrote:
>> On 2023-02-17 15:16, Simon Clubley wrote:
>>> On 2023-02-17, Arne Vajhøj <arne@vajhoej.dk> wrote:
>>>>
>>>> strcspn will stop when it reach the terminating null byte.
>>>>
>>>
>>> Are you sure about that ?
>>>
>>> https://linux.die.net/man/3/strcspn
>>>
>>> There's no mention of stopping at a null and no mention of what the
>>> return value is when the byte is not found within the string if it
>>> were to stop at a terminating null.
>>
>> Quoting the man-page I have locally:
>>
>> The strcspn() function spans the initial part of the null-terminated
>> string s as long as the characters from s do not occur in the null-
>> terminated string charset (it spans the complement of charset).
>> In other
>> words, it computes the string array index of the first character of s
>> which is also in charset, else the index of the first null character.
>>
>>
>
> BSD ?

Sortof. MacOS. BSD derivate in other words.
Checked NetBSD right now. A bit little different wording, but better
than Linux still.

Johnny

Pages:123
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor