Computer Old Farts Forum
 help / color / mirror / Atom feed
From: peter at rulingia.com (Peter Jeremy)
Subject: [COFF] [TUHS] buffer overflow (Re: Happy birthday Morris worm
Date: Wed, 13 Nov 2019 19:37:26 +1100	[thread overview]
Message-ID: <20191113083726.GF50716@server.rulingia.com> (raw)
In-Reply-To: <5d8d9933-1213-3f07-02e0-f3ad5c293de4@kilonet.net>

On 2019-Nov-12 17:49:46 -0500, Arthur Krewat <krewat at kilonet.net> wrote:
>On 11/12/2019 5:41 PM, Robert Clausecker wrote:
>> Oh please no.  One of the things we've hopefully all learned from Pascal
>> is that length-prefixed strings suck because you can't perform anything
>> useful without copying the entire string.

Keep in mind that C doesn't have a "string" type.  The use of a NUL
terminated char array is purely convention.  There's nothing to stop
someone using a length-prefixed array (though there's virtually no
standard library support for that).

>> Rob Pike and friends showed
>> how to get strings and vectors right in the Go language where you have a
>> builtin slice type which is essentially a structure
>>
>>      struct slice(type) {
>>              type *data;
>>              size_t len, cap;
>>      };

That approach would have incurred a 12-byte overhead for each string or
vector on a PDP-11 - that would have been a substantial disincentive on
a memory-constrained system.

>And none of that stops some programmer from doing slice.cap=255 - or is 
>it read-only? ;)

Slices and strings are built-in types in Go.  They can be modelled as the
above structure but that is an implementation detail.  It is possible to
reduce the capacity of a slice (but not a string) but attempting to
increase it will result in a runtime exception ("panic" in Go speak).

-- 
Peter Jeremy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 963 bytes
Desc: not available
URL: <http://minnie.tuhs.org/pipermail/coff/attachments/20191113/0564e548/attachment.sig>


      parent reply	other threads:[~2019-11-13  8:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1573592179.5935.for-standards-violators@oclsc.org>
     [not found] ` <20191112221053.C2009156E80B@mail.bitblocks.com>
     [not found]   ` <alpine.BSF.2.21.9999.1911130944090.11612@aneurin.horsfall.org>
     [not found]     ` <CANCZdfrnOfxV-TP09Ye15FVLKuZAAudEd=FQ-iULgE1js4ra4Q@mail.gmail.com>
2019-11-13  1:11       ` dave
2019-11-13  1:14         ` dave
     [not found]   ` <20191112221418.GJ16268@mcvoy.com>
     [not found]     ` <20191112224151.GA36336@fuz.su>
     [not found]       ` <5d8d9933-1213-3f07-02e0-f3ad5c293de4@kilonet.net>
2019-11-13  8:37         ` peter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191113083726.GF50716@server.rulingia.com \
    --to=coff@minnie.tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).