From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 1331 invoked from network); 21 Sep 2020 19:57:35 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 21 Sep 2020 19:57:35 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id B78DB9CAF8; Tue, 22 Sep 2020 05:57:32 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id BD77493D33; Tue, 22 Sep 2020 05:57:01 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="L81ZJFau"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id F301E93D33; Tue, 22 Sep 2020 05:56:57 +1000 (AEST) Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) by minnie.tuhs.org (Postfix) with ESMTPS id 9818493D06 for ; Tue, 22 Sep 2020 05:56:56 +1000 (AEST) Received: by mail-qk1-f182.google.com with SMTP id d20so16549869qka.5 for ; Mon, 21 Sep 2020 12:56:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qbJwDvz1IqukGa2J84aoE+bEHRffDldpScT+ESoeOp4=; b=L81ZJFauNmLJbs4rCjPFBrEzMYnywmJ4Dkpwr2P8d+cTfH+eYo4YFB7nYyYIRkx6dY R1jZHhwsDUB7uwUqH/9m3spvCqdNfqe2uP8vHCIzgf/OpRnvuygysQ5knM0zKKwvQmPe kWrzWCnfGOD89jYMJFA8rK8aULNXY39QDV0aAI8cUWzCtEKWUfaz83tZELP4B4gs/bTZ 237xXJWRXeLjw1XzdY97+UCWBzbFEJW7WQi0cHlqu700M0gqFrrBSBzomGFuasLQ/pp3 haDHniDrOMfdw9OxP1exFuIsEOdXUDcM6ZKFU1K8rqGTFjBj1eMAAI3T7C3LnhozlQ2h bN8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qbJwDvz1IqukGa2J84aoE+bEHRffDldpScT+ESoeOp4=; b=pEvHwFCM3QQhBTqQBpAdTGRYzKfXWiARZM6dQYbHipxRFrxeSx2tEYamP5/1CyfQCW u90Y/MM/98FJGlR/WYiOUW8DMaQZpN+SEUG4DHUJ+dYKuLmPwuj572KLyeeMsdhpo/sy 2VZakoDknYX5PJnAhY5GqcWk1/i9/qR00rwyAizCqmexDjZEIKcBpCa8rp0FAiszEqON kWb7HXZ1HlikdausQD24QOZsU5XiDzI5DcnkPkvaNaVExE84EbONTcvk6f9XmOgr2gO1 uoj0kpwYgxxUHZ6g0zyQzpLVImpsOQjLmsSI1kuvkS6RCzNZs38twcz0TrobSGACkzj/ AlTQ== X-Gm-Message-State: AOAM533FNFvfz1mntWorfWQTmHHihjTrEdPP0J9M6xuum71BGPI9PYzh 6qr5hxSvnnWIB08lsxBRmQc1TF258rUixvZjW1w= X-Google-Smtp-Source: ABdhPJwr3BNaJMtmtPe/hBT+iTczor2D6j/2CytGiD2Nl7ZxPbg5oyMrNUiaOfKZKPRTKLgqT1/zop9StA3wuX34N3A= X-Received: by 2002:a37:9301:: with SMTP id v1mr1529997qkd.350.1600718215507; Mon, 21 Sep 2020 12:56:55 -0700 (PDT) MIME-Version: 1.0 References: <20200920230057.C5D1A4422E@lignose.oclsc.org> In-Reply-To: From: Dan Cross Date: Mon, 21 Sep 2020 15:56:19 -0400 Message-ID: To: Paul Winalski Content-Type: multipart/alternative; boundary="0000000000009ef1cc05afd840dc" Subject: Re: [TUHS] reviving a bit of WWB X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: The Eunuchs Hysterical Society Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" --0000000000009ef1cc05afd840dc Content-Type: text/plain; charset="UTF-8" On Mon, Sep 21, 2020 at 2:40 PM Paul Winalski wrote: > VAX/VMS was the first operating system I encountered where 0 was not a > valid program address. As was mentioned previously, address space on > early machines was too precious to throw away a whole page of it just > to catch bad null pointer references. > > I once saw a C program that depended on 0 being a valid pointer > address, and on a 0x00 byte being at memory address 0. The program > had a bunch of char* pointers that were used in a printf() call, > something like: > > printf("%s%s%s%s\n", a, b, c, d); > > If you didn't want, say, the third string printed, you assigned NULL > to variable c. That caused c to point to location 0, and printf() > interpreted the 0 byte as the empty string "". > > It was hell getting this program to work on the VAX. That sounds annoying, but not necessarily insurmountable? I imagine you could wrap it in something like: void print4(char *a, char *b, char *c, char *d) { if (a == NULL) a = ""; if (b == NULL) b = ""; if (c == NULL) c = ""; if (d == NULL) d = ""; printf("%s%s%s%s\n", a, b, c, d); } ? I guess if it was more complex than that, like say being variadic, it'd be really annoying because you'd have to walk the arguments and accumulate them and assign pointers to empty strings as appropriate, or just wrap printf and interpret the format string. - Dan C. --0000000000009ef1cc05afd840dc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, Sep 21, 2020 at 2:40 PM Paul Winalski <paul.winalski@gmail.com> wro= te:
VAX/VMS was the first operating system I encountered where 0= was not a
valid program address.=C2=A0 As was mentioned previously, address space on<= br> early machines was too precious to throw away a whole page of it just
to catch bad null pointer references.

I once saw a C program that depended on 0 being a valid pointer
address, and on a 0x00 byte being at memory address 0.=C2=A0 The program had a bunch of char* pointers that were used in a printf() call,
something like:

printf("%s%s%s%s\n", a, b, c, d);

If you didn't want, say, the third string printed, you assigned NULL to variable c.=C2=A0 That caused c to point to location 0, and printf()
interpreted the 0 byte as the empty string "".

It was hell getting this program to work on the VAX.

<= /div>
That sounds annoying, but not necessarily insurmountable? I imagi= ne you could wrap it in something like:

void
print4(char *= a, char *b, char *c, char *d)
{=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (a =3D=3D NULL) a =3D "";=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (b =3D= =3D NULL) b =3D "";
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 if (c =3D=3D NULL) c =3D "";
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (d =3D=3D NUL= L) d =3D "";
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 printf("%s%s%s%s\n", a, b, c, d);
<= div>}
?

I guess if it was more compl= ex than that, like say being variadic, it'd be really annoying because = you'd have to walk the arguments and accumulate them and assign pointer= s to empty strings as appropriate, or just wrap printf and interpret the fo= rmat string.

=C2=A0 =C2=A0 =C2=A0 =C2=A0 - Dan C.<= /div>

--0000000000009ef1cc05afd840dc--