Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.raspberry-pi > #10829
| From | Björn Lundin <b.f.lundin@gmail.com> |
|---|---|
| Newsgroups | comp.sys.raspberry-pi |
| Subject | Re: installation |
| Date | 2016-02-26 15:47 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <napod3$e9t$1@dont-email.me> (permalink) |
| References | (12 earlier) <nansi9$lt4$1@dont-email.me> <4PqdndYB5-NnBVLLnZ2dnUU7-IGdnZ2d@giganews.com> <nao635$abb$1@news.albasani.net> <napmju$7ov$1@dont-email.me> <napnda$6ur$1@news.albasani.net> |
On 2016-02-26 15:27, The Natural Philosopher wrote:
> On 26/02/16 14:17, Björn Lundin wrote:
>> On 2016-02-26 01:26, The Natural Philosopher wrote:
>>>
>>> If you remember that C is no more than a fast way to write assembler,
>>> and gives you the ultimate power to fuck up totally, you wont make these
>>> beginner mistakes.
>>
>> This is of course true.
>> But the very idea of 'have to remember' when a compiler can do that for
>> you is icky - in my point of view.
>>
>> To get back on the pi-track, I have written several things in python,
>> from utilities to small bot-systems betting on UK/IE horse races,
>> but the lack of compiler makes me do mistakes (like indentation, or
>> trying to print an int on stdout without conversion)
>> which then becomes run-time crashes.
>>
>> Yes I do know about pylint, but it has to be configured
>> and set up, which I don't HAVE to do, thus I don't do it.
>>
>> A strict compiler, that is my best friend.
>>
>>
> I do agree. That picks up most of the inadvertent casting issues.
>
> But it doesn't pick up buffer overflows.
>
> Over the years I have basically asked myself two questions
>
> (a) Is it possible the data going in this buffer could be larger than
> the buffer?
> (b) If so, what would happen if I restricted the data to the buffer
> size, or threw an error?
>
> There are other options,. like always using malloced data after doing a
> len() or strdup or whatever, but these all imply that you already have
> the data in a suitably large buffer..
>
> If its coming in a byte at a time, you have to accept the overhead of
> checking it its out of bounds ...but that is better than having run time
> checking enforced by the language whether you need it or not.
If the compiler knows enough, that is if you have
a strongly types language, the effect will actually be that
some run time checks are eliminated.
a simple for loop in c over an array
int len = 200;
int data[len] ;
for (int i=0; i<len; i++ ) {
// do something with data[i]
}
for each turn in the loop
a comparison if i<len is made
However below, the compiler knows the boundaries of the array
so that check is usually optimsed away
data : array(1..200) of Integer;
for i in data'range loop
-- do something with data(i)
end loop;
As for buffer overflows, I really can't see it happen at all in Ada.
Trying to write to element 201 in above array would get me an exception
(Constraint_Error)
while in C
for (int i=0; i<=len; i++ ) {
// do something with data[i]
}
will get me undefined behavior
That being said, I think this evolved a bit too far out for a Raspberry
pi group.
--
Björn
Back to comp.sys.raspberry-pi | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
installation T M Smith <tmsmith36@tmsmith36.plus.com> - 2016-02-22 22:12 +0000
Re: installation "A. Dumas" <alexandre@dumas.fr.invalid> - 2016-02-22 23:33 +0100
Re: installation T M Smith <tmsmith36@tmsmith36.plus.com> - 2016-02-22 22:47 +0000
Re: installation Rob <nomail@example.com> - 2016-02-22 23:13 +0000
Re: installation "M.O.B. i L." <mobil@orbin.se> - 2016-02-23 00:15 +0100
Re: installation T M Smith <tmsmith36@tmsmith36.plus.com> - 2016-02-22 23:12 +0000
Re: installation "A. Dumas" <alexandre@dumas.fr.invalid> - 2016-02-23 01:26 +0100
Re: installation Rob <nomail@example.com> - 2016-02-23 08:40 +0000
Re: installation "A. Dumas" <alexandre@dumas.fr.invalid> - 2016-02-23 11:03 +0100
Re: installation Rob <nomail@example.com> - 2016-02-23 12:24 +0000
Re: installation "A. Dumas" <alexandre@dumas.fr.invalid> - 2016-02-23 14:42 +0100
Re: installation T M Smith <tmsmith36@tmsmith36.plus.com> - 2016-02-23 20:47 +0000
Re: installation T M Smith <tmsmith36@tmsmith36.plus.com> - 2016-02-23 20:30 +0000
Re: installation Rob Morley <nospam@ntlworld.com> - 2016-02-24 00:20 +0000
Re: installation T M Smith <tmsmith36@tmsmith36.plus.com> - 2016-02-24 19:55 +0000
Re: installation Rob <nomail@example.com> - 2016-02-24 08:47 +0000
Re: installation Jean-Pierre Kuypers <Kuypers@address.invalid> - 2016-02-24 09:55 +0100
Re: installation Martin Gregorie <martin@address-in-sig.invalid> - 2016-02-24 18:47 +0000
Re: installation T M Smith <tmsmith36@tmsmith36.plus.com> - 2016-02-24 20:15 +0000
Re: installation Jean-Pierre Kuypers <Kuypers@address.invalid> - 2016-02-24 23:05 +0100
Re: installation Martin Gregorie <martin@address-in-sig.invalid> - 2016-02-24 22:36 +0000
Re: installation "A. Dumas" <alexandre@dumas.fr.invalid> - 2016-02-25 00:24 +0100
Re: installation "A. Dumas" <alexandre@dumas.fr.invalid> - 2016-02-25 00:29 +0100
Re: installation Roger Bell_West <roger+csrp201602@nospam.firedrake.org> - 2016-02-25 00:25 +0000
Re: installation "A. Dumas" <alexandre@dumas.fr.invalid> - 2016-02-25 11:09 +0100
Re: installation Rob <nomail@example.com> - 2016-02-25 14:46 +0000
Re: installation T M Smith <tmsmith36@tmsmith36.plus.com> - 2016-02-25 21:32 +0000
Re: installation Martin Gregorie <martin@address-in-sig.invalid> - 2016-02-25 23:45 +0000
Re: installation "A. Dumas" <alexandre@dumas.fr.invalid> - 2016-02-26 04:33 +0100
Re: installation Martin Gregorie <martin@address-in-sig.invalid> - 2016-02-26 08:56 +0000
Re: installation T M Smith <tmsmith36@tmsmith36.plus.com> - 2016-02-26 22:00 +0000
Re: installation Jean-Pierre Kuypers <Kuypers@address.invalid> - 2016-02-26 23:32 +0100
Re: installation T M Smith <tmsmith36@tmsmith36.plus.com> - 2016-02-26 22:53 +0000
Re: installation alister <alister.ware@ntlworld.com> - 2016-02-26 23:57 +0000
Re: installation T M Smith <tmsmith36@tmsmith36.plus.com> - 2016-02-27 00:15 +0000
Re: installation "A. Dumas" <alexandre@dumas.fr.invalid> - 2016-02-27 15:04 +0100
Re: installation Charlie <cdknospam@msn.com> - 2016-02-27 12:53 -0500
Re: installation T M Smith <tmsmith36@tmsmith36.plus.com> - 2016-02-27 21:41 +0000
Debian: version vs. code name (was: installation) Jean-Pierre Kuypers <Kuypers@address.invalid> - 2016-03-02 11:04 +0100
installation nospam.mark.lewis@p73.f12.n3634.z1.binkp.net (mark lewis) - 2016-02-24 17:44 +1200
Re: installation T M Smith <tmsmith36@tmsmith36.plus.com> - 2016-02-25 21:13 +0000
Re: installation Martin Gregorie <martin@address-in-sig.invalid> - 2016-02-25 23:39 +0000
Re: installation The Natural Philosopher <tnp@invalid.invalid> - 2016-02-23 10:24 +0000
Re: installation Hils <hils@saynotospam.net> - 2016-02-23 13:25 +0000
Re: installation colonel_hack@yahoo.com - 2016-02-25 21:04 -0700
Re: installation mm0fmf <none@invalid.com> - 2016-02-22 22:35 +0000
Re: installation T M Smith <tmsmith36@tmsmith36.plus.com> - 2016-02-22 22:42 +0000
Re: installation alister <alister.ware@ntlworld.com> - 2016-02-23 10:04 +0000
Re: installation Charlie <cdknospam@msn.com> - 2016-02-23 08:55 -0500
Re: installation mm0fmf <none@invalid.com> - 2016-02-23 18:21 +0000
Re: installation The Natural Philosopher <tnp@invalid.invalid> - 2016-02-23 18:28 +0000
Re: installation alister <alister.ware@ntlworld.com> - 2016-02-23 19:48 +0000
Re: installation mm0fmf <none@invalid.com> - 2016-02-23 22:49 +0000
Re: installation alister <alister.ware@ntlworld.com> - 2016-02-24 10:40 +0000
Re: installation The Natural Philosopher <tnp@invalid.invalid> - 2016-02-24 10:50 +0000
Re: installation Folderol <general@musically.me.uk> - 2016-02-24 11:25 +0000
Re: installation The Natural Philosopher <tnp@invalid.invalid> - 2016-02-24 12:37 +0000
Re: installation Björn Lundin <b.f.lundin@gmail.com> - 2016-02-25 18:26 +0100
Re: installation Rob Morley <nospam@ntlworld.com> - 2016-02-25 17:42 +0000
Re: installation Björn Lundin <b.f.lundin@gmail.com> - 2016-02-25 22:46 +0100
Re: installation Michael J. Mahon <mjmahon@aol.com> - 2016-02-25 18:14 -0600
Re: installation The Natural Philosopher <tnp@invalid.invalid> - 2016-02-26 00:26 +0000
Re: installation Michael J. Mahon <mjmahon@aol.com> - 2016-02-25 22:39 -0600
Re: installation Ahem A Rivet's Shot <steveo@eircom.net> - 2016-02-26 09:33 +0000
Re: installation The Natural Philosopher <tnp@invalid.invalid> - 2016-02-26 10:05 +0000
Re: installation Michael J. Mahon <mjmahon@aol.com> - 2016-02-26 17:48 -0600
Re: installation Björn Lundin <b.f.lundin@gmail.com> - 2016-02-26 15:17 +0100
Re: installation The Natural Philosopher <tnp@invalid.invalid> - 2016-02-26 14:27 +0000
Re: installation Björn Lundin <b.f.lundin@gmail.com> - 2016-02-26 15:47 +0100
Re: installation Michael J. Mahon <mjmahon@aol.com> - 2016-02-26 17:48 -0600
Re: installation "A. Dumas" <alexandre@dumas.fr.invalid> - 2016-02-26 15:32 +0100
Re: installation Martin Gregorie <martin@address-in-sig.invalid> - 2016-02-26 09:22 +0000
Re: installation Björn Lundin <b.f.lundin@gmail.com> - 2016-02-26 15:18 +0100
Re: installation Rob Morley <nospam@ntlworld.com> - 2016-02-24 12:46 +0000
Re: installation The Natural Philosopher <tnp@invalid.invalid> - 2016-02-24 13:28 +0000
Re: installation mm0fmf <none@invalid.com> - 2016-02-24 18:42 +0000
Re: installation alister <alister.ware@ntlworld.com> - 2016-02-24 21:49 +0000
Re: installation druck <news@druck.org.uk> - 2016-02-25 13:24 +0000
Re: installation ray carter <ray@zianet.com> - 2016-02-22 23:20 +0000
csiph-web