473,473 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Coding the DJB way?

Hi there,

in the document available at http://cr.yp.to/2004-494/0825.pdf
DJB says that a construct like:

while (*tz != '\0')
*q++ = *tz++;

would make it possible to take over the machine by a local user.
What does he mean exactly with his statement? Can anyone shed
some light on that? I don't really understand this. Is there a resource
that explains a bit more the coding style DJB used? I have had a
look at his API and his internal helper functions used in his software,
and I'd like to understand them more than I do now.

Cheers,
JR
Nov 15 '05 #1
4 2413
Jan Richter wrote:
Hi there,

in the document available at http://cr.yp.to/2004-494/0825.pdf
DJB says that a construct like:

while (*tz != '\0')
*q++ = *tz++;

would make it possible to take over the machine by a local user.
What does he mean exactly with his statement? Can anyone shed
some light on that? I don't really understand this.
Read the *entire* document, not just the first few pages. The rest of
them are about stacks, and the (in)famous buffer over/underflow, where
this is all about.
Is there a resource
that explains a bit more the coding style DJB used? I have had a
look at his API and his internal helper functions used in his software,
and I'd like to understand them more than I do now.


It's usually about 1 think : Don't trust input you don't generate, and
make sure a function does what it is suppose to. For example : Don't
assume that a char * is NULL terminated, use strlcpy() to make sure the
result always is, no matter what the input is.
Igmar
Nov 15 '05 #2
"Jan Richter" <vi**********@yahoo.de> wrote:
in the document available at http://cr.yp.to/2004-494/0825.pdf
DJB says that a construct like:

while (*tz != '\0')
*q++ = *tz++;

would make it possible to take over the machine by a local user.
What does he mean exactly with his statement?
Nothing, AFAICT. That is, he promises that it will be explained later
on, but it isn't. There's just some (inaccurate and highly system-
dependent) platitudes about stacks.
Can anyone shed some light on that? I don't really understand this.


You needn't. Without a lot more context, his statement is meaningless.

Yes, it _is_ possible to write a program which, as a whole, is so broken
that it would allow "a local user" to "take over the machine", for some,
again highly system-dependent, meaning of those phrases. But if you do,
the error is not just in the lines as he quotes them. It is also quite
possible to write a correct program, with no security hole, in which
such lines occur.

(That said, it is a silly bit of code, since we have strcpy().)

Richard
Nov 15 '05 #3
Jan Richter wrote:
Hi there,

in the document available at http://cr.yp.to/2004-494/0825.pdf
DJB says that a construct like:

while (*tz != '\0')
*q++ = *tz++;

would make it possible to take over the machine by a local user.
What does he mean exactly with his statement? Can anyone shed
some light on that? I don't really understand this. Is there a resource
that explains a bit more the coding style DJB used? I have had a
look at his API and his internal helper functions used in his software,
and I'd like to understand them more than I do now.


The control statement above is semantically equivalent to

while (*tz != '\0') {
*q = *tz;
tz++;
q++;
}

which has the same effect as

i = 0;
while (tz[i] != '\0') {
q[i] = tz[i];
i++;
}

Note that the string copied to q is not terminated by '\0'.
August
Nov 15 '05 #4
Jan Richter wrote:
in the document available at http://cr.yp.to/2004-494/0825.pdf
DJB says that a construct like:

while (*tz != '\0')
*q++ = *tz++;

would make it possible to take over the machine by a local user.


Not exactly. He's saying that such code did make it possible in one
particular instance. He quoted the code exactly and paraphrased the
release note (which says that it's a local root vulnerability). You
can find the faulty code, the fixed code, and the release note in this
file:

http://www.sendmail.org/ftp/past-rel...il.8.7.6.patch

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ganesan | last post by:
Hi Guys, Could any one knows the best coding standards styles(with variable declarations for c#) . and if any links or site with the best coding standards for .NET send me those links regards...
4
by: dotNetDave | last post by:
About three weeks ago I released the first .NET coding standards book titled "VSDN Tips & Tricks .NET Coding Standards". Here is what the famous author/ speaker Deborah Kurata says about it: ...
0
by: Berthold Höllmann | last post by:
I have a default coding header # -*- coding: iso-8859-15 -*- in my python files. I now have Problems with this settings. I swithched to Python 2.4.1 under Windows. When I import files with the...
144
by: Natt Serrasalmus | last post by:
After years of operating without any coding standards whatsoever, the company that I recently started working for has decided that it might be a good idea to have some. I'm involved in this...
7
by: Ralph Lund | last post by:
Hi. I am starting a new project with C#. I am searching for "good" coding conventions. I know that there are some coding conventions from microsoft, (but they are very extensive and not clear)....
13
by: benben | last post by:
Is there an effort to unify the c++ coding standard? Especially identifier naming. Not a big issue but it would be annoying to have to incorporate different coding styles simultaneously when...
7
by: Robert Seacord | last post by:
The CERT/CC has just deployed a new web site dedicated to developing secure coding standards for the C programming language, C++, and eventually other programming language. We have already...
3
by: editormt | last post by:
A recent poll asked if programming standards are used by development organisations... and if they are controlled. None: 20% Yes, but without control: 49% Yes, with control: 31% Participants:...
0
by: pat | last post by:
CodeCheck Coding Standard's Support As a free service to our customers we offer support in developing "rule-files" for automating corporate coding standards. If you have a coding standard that...
8
by: =?ISO-8859-1?Q?Arnaud_Carr=E9?= | last post by:
Hi all, I guess you all know how difficult it is to choose a conding standard. And even more difficult it is to explain the choice to your dev team :-) I'm looking for an "official" c++ coding...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.