473,883 Members | 2,426 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listing the most dangerous parts of C

I am looking for a wish list of things which should be removed from
the C (C99) - due to feature's bad security track record <OT>or
Multithreading unsafety. I need this list for a project intending to
build another (easiest & most powerful) programming language, which
has a two page definition document stating: "... includes C
programming language (C99), except its famous
"avoid-using-this-functions". </OT>

If you would not want to remove a whole function but only the use of
it with certain arguments / parameters, what would those combinations
be like? (Like scanf with %s or %[ arguments )

Probably there are official not to use recommendation lists.
( million times better than this)
http://tele3d.com/wiki/index.php/Par...ncluded_in_t3d

Please, do not circumvent the question by saying all functions except
gets() are safe if used properly. That would be like teaching that
"the ideology of Soviet Union was right, it was the Soviet peoples
fault that the system didn't work.

Juuso Hukkanen
(to reply by e-mail set addresses month and year to correct)
www.tele3d.com

May 10 '06
62 4160
On Wed, 10 May 2006 12:05:13 -0400 (EDT), "Arthur J. O'Dwyer"
<aj*******@andr ew.cmu.edu> wrote:
... This guy's been pushing its "natural language, giant
built-in library of functions" model for at least a year or so, now.
(The problems are that the "natural" language isn't, and the "built-in"
functions aren't.)
Firstly thank for very the good scanf examples. But otherwise your
characterizatio n was not too fair. Firstly the language was published
for the October 2005. Since then I have just been busy and apart from
this hobby.
Assumingly you already understood and learned the programming
language - because you could state it being "natural language
giant-built-in-library of functions". Now compare how long it took to
learn other languages. I don't believe you have anything to complain
about the language itself, but you rather want to insult me and the
newness of this thing.

So is it such a bad thing, if all the good functions get written
properly (only) once and then nobody again need to write that function
from the scratch again.

I am 100% sure that even Arthur J. O'Dwyer would prefer to call a
function,
t3d_convert_fil e_Rfile_WAV2OGG _BITRATEXXX
, than to try to write a similar doing function - Right?
(The problems are that the "natural" language isn't, and the "built-in"
functions aren't.)


Assumingly that you admit that you to have learned this "natural"
language. Well
PHP created by Rasmus Lerdorf in 1994; How popular was it 8 months
after its release - not very. In June 1995 he posted info about those
PHP modules to UseNET for others who might be interested in them.
http://groups.google.com/group/comp....7d43454d64d133

Appears to be kind of similar project as this language project - And
probably Rasmus had not at that stage written the currently thousand
of functions in the PHP source library.

What did we learn, I don't know …and I can not say whether the thing
will succeed also because defining the success is not that simple (see
my reply to Jacob).

Want to see sources - help yourself:
Initial codes to pre-preprocessor & library routines:
http://www.tele3d.com/t3d/subversion.htm
http://www.tele3d.com/t3d/DEVEL/
Greetings
Juuso Hukkanen
(to reply by e-mail set addresses month and year to correct)
www.tele3d.com
May 10 '06 #11
On Wed, 10 May 2006 17:47:47 +0200, jacob navia wrote:
What is "t3d" first ???


Short question - long semi OT answer

It is a super-simple (documentation two pages) C based programming
language, with safe strings, (boehm) garbage collection, networking,
exact datatypes, GUI, multi-threading, environment etc.

Ok, key thing is that all the function calls are formulated as being
logical sentences.

You have 15 verbs: add, remove, convert, open,write…
You also have 20 objects (datatypes): byte, double, file, filepath,
url…

Then you just combine a:
verb --- > to which object the verb action is to be done ---> to which
object the results are to be written ---> and at the end you tell how
the verb action is to be done

t3d_calculate_i array_Rdouble_S TD_DEVIATION
t3d_convert_fil e_Rfile_GSM2WAV
t3d_measure_bar ray_LENGTH
t3d_convert_Rfi le_READ_ONLY

The flexibility and the logicality of the t3d function prototypes
allows you to easily create or use all kinds routines. Even using
routines you didn't know to exist. Bonus is that the function
prototype works using any of the words written languages (try for
example in France).

t3d_calcule_fic hier_Rdécimal_D EVIATION_STANDA RD
Ok, the idea is to use C99 as much as possible but when it's not
possible then use the platform specific C extensions.
Ok, Internet is full of weird programming languages and the
competition is tough - However sometimes new programming languages do
succeed - like PHP did. I believe t3d has lots of unique qualities due
to its easiness, raw power and multi-language support.
I have a dream, I don't know if it is realizable but I try donate
the t3d language to one of the major charity organization, under a
license owned by a bunch of charity organizations. --> Therefore all
the programs that would be made e.g. by using those "ultimate t3d
libraries" or any other "under the license" staff would require a
license from some of the listed charity organizations. The charity
license would be like a dual - GPL allowing individuals to use the
software freely, while the rich country companies would require a
license.

This way the coders (anywhere) could decide to donate their opensource
works to charity organizations instead as currently donating them to
Free Software Foundation using the GPL2. The reason why I keep the
hobby of promoting the language and the (even more important) license
idea is that I sense that if this thing would succeed it could make a
big impact. Currently the Amnesty International, Red Cross and the
Greenpeace International are evaluating the license - who knows they
might like it or decide to write their own version.

Naturally it is impossible for me to write a whole language and I am
not that good coder either, but who knows what happens if for example
Slashdot would one day announce that
"Amnesty has a programming language & new OS license"

I bet there would be few programmers who would consider supporting the
initiative of building the t3d programming language ready.

Juuso Hukkanen
(to reply by e-mail set addresses month and year to correct)
"t3d programming language" and the structure of t3d function prototype
are trademarks of Juuso Hukkanen. (As said currently discussing the
transfer of those to a major charity organization).
May 10 '06 #12
Juuso Hukkanen wrote:

I am looking for a wish list of things which should be removed from
the C (C99) - due to feature's bad security track record <OT>or

[...]

I've always thought that "the most dangerous part of C" was the programmer.

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer .h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th***** ********@gmail. com>

May 10 '06 #13
Kenneth Brody wrote:
Juuso Hukkanen wrote:
I am looking for a wish list of things which should be removed from
the C (C99) - due to feature's bad security track record <OT>or


[...]

I've always thought that "the most dangerous part of C" was the programmer.


Yeah you are right!

ELIMINATE THEM!!!!!

May 10 '06 #14
Juuso Hukkanen wrote:

http://www.ida.liu.se/~johwi/researc...ate_thesis.pdf

Chapter 7.3.3 Functions which are for attracting buffer overflows
Chapter 7.3.5 Format string vulnerabilities

very good reading , and it gives references to another even better
says...

<snip>
Functions to avoid in most cases (or ensure protection) include the
functions, strcpy(3), strcat(3), sprintf(3) (with cousin vsprintf(3)),
and gets(3). These should be replaced with functions
such as strncpy(3), strncat(3), snprintf(3), and fgets(3)
respectively, but see the discussion below. The
function strlen(3) should be avoided unless you can ensure that there
will be a terminating NIL character to find.


That looks like good advice for programmers
who don't know that string functions are for using with strings,
but who want to use string functions anyway.

--
pete
May 10 '06 #15
On 2006-05-10, Rod Pemberton <do*********@bi tfoad.cmm> wrote:

If you really want to get crazy with C, do some of these:
1) eliminate pointers in main Seems like any problems associated with that would be poor programming practice.
2) make pointers be associated with a variable before use, not with a data
type Ditto.
3) eliminate malloc, add dynamic allocation and garbage collection Now you've got a Java-like beast, only to solve programmers who can't keep
track of memory.
4) change C to pass by reference Make that C++... for the same reason.
5) require separation of string (and other) data and flow control
information I believe that is implementation-defined right now, and in some situations, such
as embedded systems, it could be problematic.
6) give up now, and try Walter Bright's D language...

I think I'll check that out...

Basically, as has been said, C's most dangerous aspect is the programmer, and
any functions that might seem worth ditching /do/ have a purpose. Except for
gets(), which has no safe usage.
May 10 '06 #16
qed
Juuso Hukkanen wrote:
I am looking for a wish list of things which should be removed from
the C (C99) - due to feature's bad security track record <OT>or
Multithreading unsafety. I need this list for a project intending to
build another (easiest & most powerful) programming language, which
has a two page definition document stating: "... includes C
programming language (C99), except its famous
"avoid-using-this-functions". </OT>

If you would not want to remove a whole function but only the use of
it with certain arguments / parameters, what would those combinations
be like? (Like scanf with %s or %[ arguments )

Probably there are official not to use recommendation lists.
( million times better than this)
http://tele3d.com/wiki/index.php/Par...ncluded_in_t3d


You are recommending strncpy and strncat. These are slow functions that
occasionally leave off the terminating '\0'. I would argue that they
are therefore *WORSE* than that functions they replace. Others would
recommend strlcpy/strlcat as superior alternatives. (But limited --
obviously I would recommend removing all of str* and add in Bstrlib as
an alternative, but, I've said this before, and this is likely beyond
what you are looking at/for.)

fgets is not an ideal substitute for gets as explained here:
http://www.pobox.com/~qed/userInput.html (though obviously gets must be
removed.) So I would also recommend removing fgets if you have a
replacement for it (such as getInputFrag, or perhaps just fgetstr)

I am not sure why you want to get rid of srand() or rand(). Its true
they suck as PRNGs, and race conditions mess them up in ways that can be
worse than you think (and RAND_MAX is generally pathetically small), but
I don't think people generally abuse them to that degree of detriment in
the real world. Again, if you had a *substitute*, that would be fine.
The problem is that I am not aware of any good portable PRNGs -- are you
(hence supporting the idea that C is not a portable language)? As for
non-portable ones, there are plenty (such as Mersenne Twister, or any of
the Marsaglia generators.) So as long as we are stuck with *something*
-- they still can serve a role as a quick and dirty PRNG. (The right
answer here is to demand that the standard change how it works --
however a quick perusal of their guiding principles, indicates there is
no mechanism by which you could reasonably do this.)

Ok, as for other things that should obviously be removed: ftell() and
fseek(). Use fgetpos() and fsetpos() as the alternatives. (ftell and
fseek are simply not defined to have any useful functionality beyond
fgetpos/fsetpos and are incredibly deceptive in how they *appear* to work.)

I would get rid of ungetc just on principle (can't unread at the
beginning of a file, may screw up fgetpos(), only does a single
character -- its just super lame, and throws a monkey wrench into too
many other functions.)

The complex number type from C99 is in clear namespace conflict with
C++. This isn't a minor issue, since accomidating for it would
drastically reduce C++'s functionality/usefulness (C++ implements
complex numbers as a template, so that you can implement things like
Guassian Integers for example). As such, I would recommending removing
that whole set of such operations.

Ok, as to core language things -- there is also the strange issue of
function pointers. If you say:

void (* qs) (void*,size_t,s ize_t,int (*)(const void*,const void*));
qs = qsort;
qs = &qsort;

there is no syntax error or conflict between the last two lines (in fact
they do and mean the same thing). This means if you want to express a
pointer to a function pointer, matters are not obvious. So one or the
other should be removed.

Of course I think "register" and "inline" are functional placebos in
modern C compilers. They are also deceptively named (both should be
replaced by a single adjective "nonaddressable " or something like that.)

C also accepts things like 3[a] as equivalent to a[3], when there
doesn't seem to be a really good reason to do this. This appears to be
strictly for the obfuscated C code competition.

--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/
May 11 '06 #17
Kenneth Brody wrote:
Juuso Hukkanen wrote:
I am looking for a wish list of things which should be removed from
the C (C99) - due to feature's bad security track record <OT>or

[...]

I've always thought that "the most dangerous part of C" was the programmer.

Actually, those sharp hooks at the end of the letter is what will hurt you
every time.

Of course, C++ is even more dangerous in that regard, since it adds barbed
wire. D should be safe, though.

S.
May 11 '06 #18
qed <us********@azi llionmonkeys.co m> writes:
I would get rid of ungetc just on principle (can't unread at the
beginning of a file, may screw up fgetpos(), only does a single
character -- its just super lame, and throws a monkey wrench into too
many other functions.)


I am unaware of a limitation on calling ungetc() at the beginning
of a file. I scanned the definition of ungetc() in C99 and
didn't see such a limitation--did I miss something?
--
"In My Egotistical Opinion, most people's C programs should be indented six
feet downward and covered with dirt." -- Blair P. Houghton
May 11 '06 #19
Andrew Poelstra wrote:
On 2006-05-10, Rod Pemberton <do*********@bi tfoad.cmm> wrote:
If you really want to get crazy with C, do some of these:
1) eliminate pointers in main

Seems like any problems associated with that would be poor programming practice.
2) make pointers be associated with a variable before use, not with a data
type

Ditto.
3) eliminate malloc, add dynamic allocation and garbage collection

Now you've got a Java-like beast, only to solve programmers who can't keep
track of memory.

Exactly. Garbage collection is for people who are stupid or lazy or both.
Everyone knows that keeping track of memory yourself is better and cleaner.
Keeps the mind in shape and your programs fast.

Or something like that, at least.

S.
May 11 '06 #20

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

Similar topics

4
1898
by: Chris | last post by:
Hello Am really worried, so wondered if anyone could help. My site outgrew itself recently so we've had to make changes to the url structure. I have some important url's like this: www.mysite.com/bluewidgets/, Yet now with the expansion of the site and url structure change (had to be done) we also have urls like: www.mysite.com/country1/bluewidgets/ which serves up identical content to the above first url.
3
1544
by: Mr. B | last post by:
In my application which allows a user to open specific AutoCAD script files (SCR extension), I want to intoduce a listing of the 10 most recently opened files. I know of at least two ways that I could do this: 1) Have a text file that contains the information 2) Write the info to the Registry The first is my easiest as I am familiar with TXT type files. I've never used (and have no idea how to use) a XML type file (let alone the...
3
3104
by: David Callaghan | last post by:
Hi I've just joined tesco broadband. I've come from NTL. If I don't put an index.htm on my NTL home page it justs lists the files in there when any browser visites my page. If I don't put an index.htm on my Tesco home page, I get a:
0
1604
by: kristopher | last post by:
Websites of various subjects ranging from computing to entertainment. TrafficRanking.com says that allsitecafe.com is one of the most VISITED internet sites on the web today! There are over 1,700+ sites linked to allsitecafe.com, and every site has been visited by a human being before inclusion into the allsitecafe.com database of links. You won’t find many dead links at allsitecafe.com – the database is faithfully updated every 4-6 months...
2
2917
by: cj | last post by:
Hi, I'm able to get the listing of (or "Index of") a directory on a website/webserver using HttpWebRequest and HttpWebResponse, but it comes back as an HTML page, similar to what IE or Mozilla/Firefox/Netscape would show. Is there anyway to get the listing in some other form, or do I just have to parse the info myself?
7
4755
by: JohnR | last post by:
Couldn't find it in MSDN. Does anybody have a listing of the message constants that would be received in my application.addmessagefilter routine in VB.net? They are referred to all over MSDN but I can't locate the actual listing of the constants and their values. Thanks, John
1
3380
by: Light | last post by:
Re, I'm having 2 problems with the Telerik trial controls. I'm using the latest release. I'm using 2005 studio and most of the controls show up properly in the designer but the RadMenu does not. It says "Error Creating Control" and then a ton of errors. This occurs both when I use it and in the examples but it does render properly when built. If I drag/drop the control then it shows up properly but when I apply a theme and then...
2
3275
by: Juuso Hukkanen | last post by:
I need a list of multithreading unsafe C (C99) functions/features. comp.programming.threads provided an initial list of C:ish functions, with following ANSI C functions: asctime, gmtime, localtime, ctime, tmpnam, strtok http://www.lambdacs.com/cpt/FAQ.html#Q150 However, extra Googling hinted rand() and srand(), also being unsuitable for multi-threading - opinions? And what is the status of
1
1339
by: TahoeKid | last post by:
I need to modify and assemble the assembler listing files generated from the VS 2005 IDE. A test generated listing file did not assmeble 'as is'. Has anyone tried this? It seems to me the listing file should assemble.
0
9797
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11154
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10762
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10863
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10422
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9586
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5807
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4622
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 we have to send another system
3
3241
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.