473,785 Members | 3,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using static char arrays to be on the safe side

Hi

I program primarily in C++ , but once in a while one is forced to use
the odd strcpy or call API functions that dump results into char*
buffers.

I believe that most security exploits that work by thrashing the stack
to overwrite the return address, allowing arbitrary code execution.
I have now fallen into the habit of declaring temporary buffers as
static char arrays.

Is this a good idea in general?

Are there other kinds of exploits which do not rely on stack
thrashing?
Vivek
Nov 17 '07
11 2065
rep_movsd <re*******@gmai l.comwrites:
On Nov 20, 3:52 am, CBFalconer <cbfalco...@yah oo.comwrote:
>rep_movsd wrote:
Oh well, I guess its best to avoid such "fixes" and make sure I
always know the size of the data that I strcpy or memcpy, in any
case most APIs ( at least WIN32 ones that i know of ) can be made
to return the size of the data that they will return....

Incomprehensib le. See the advice in my sig, below.

--
If you want to post a followup via groups.google.c om, ensure
you quote enough for the article to make sense. Google is only
an interface to Usenet; it's not Usenet itself. Don't assume
your readers can, or ever will, see any previous articles.
More details at: <http://cfaj.freeshell. org/google/>

--
Posted via a free Usenet account fromhttp://www.teranews.co m

Sorry, here is my original query and google groups thread link
Oh dear. Prepare for more of his signature advice because you forgot to
snip his double signature.
>
rep_movsd wrote:
>Hi
>I program primarily in C++ , but once in a while one is forced to use
the odd strcpy or call API functions that dump results into char*
buffers.
>I believe that most security exploits that work by thrashing the stack
to overwrite the return address, allowing arbitrary code execution.
I have now fallen into the habit of declaring temporary buffers as
static char arrays.
>Is this a good idea in general?

Followed up on
groups.google.c om/group/comp.lang.c/browse_thread/thread/
073b39de9430aec 9#

Vivek
Nov 23 '07 #11
Richard wrote:
[21 lines deleted]
>
Oh dear. Prepare for more of his signature advice because you forgot to
snip his double signature.
[16 lines deleted]

Richard, did you really need to quote the entire article to say that?
(Hint: No, you didn't.) (Hint: This criticism is from someone with
a valid signature; perhaps you'll pay attention to it.)

Are you incapable of trimming quoted text?

You said recently that you had killfiled CBFalconer. I had hoped
this would mean we wouldn't see any more complaints from you about
his signature(s).

--
Keith Thompson (The_Other_Keit h) <ks***@mib.or g>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Nov 23 '07 #12

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

Similar topics

7
5086
by: Vaca Louca | last post by:
Hello, My setup: Debian sarge on dual Pentium 4. g++ 3.3.5-3. (the other system is Windows XP with MS Visual Studio .NET 2003) I have an auto_array<T> template (based on a template taken from the Corona project hosted at SourceForge) which basically wants to implement std::auto_ptr<T> semantics for an array.
7
6147
by: Jim Showalter | last post by:
I always thought that it is safe for a function to return a pointer to static storage. And the following code does compile quietly with: gcc -pedantic -Wall -o foo foo.c #include <stdio.h> static char *foo (int y) { static char s;
12
2369
by: Michael B Allen | last post by:
Is it legit to modify static data like the following code? #include <stdlib.h> #include <stdio.h> struct tbl { int i; char *s; };
28
2710
by: Merrill & Michele | last post by:
#include <stdio.h> #include <string.h> #include <stdlib.h> int main(void){ char *p; p=malloc(4); strcpy(p, "tja"); printf("%s\n", p); free(p); return 0;
33
3190
by: baumann.Pan | last post by:
hi all, i want to get the address of buf, which defined as char buf = "abcde"; so can call strsep(address of buf, pointer to token);
16
3281
by: Martin Jørgensen | last post by:
Hi, I've made a program from numerical recipes. Looks like I'm not allowed to distribute the source code from numerical recipes but it shouldn't even be necessary to do that. My problem is that I'm not very experienced with pointers, pointers to pointers and the like and I got 4 compiler warnings + I don't completely understand how to build this "compact matrix" (see later).
15
2482
by: rEvolution27 | last post by:
I'm a c++ newbie here, trying out some stuff and when I try to compile this: void create() { char name; cout << "Creating a new timetable /n Please type a name for this timetable"; cin >name; ofstream editFile; editFile.open (name, ios::out | ios::app);
2
1760
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I'm using a COM DLL in my C# application (a single process). This COM DLL generates a data array, and by using the interop DLL (generated by VS/TlbImp.exe), I'm getting this array to a safe Array into my C# code (using the marshaling and all that...). My Question is: Does a multiple data arrays is allocated when marshaling the data from the COM component to my C# component. I mean; Does an array is allocated in the COM side and another...
13
2236
by: arnuld | last post by:
this does not work, i know there is some problem in the "for loop" of "print_arr" function. i am not able to correct the weired results i am getting. i have no compile time error, it is only semantic-bug that is causing the trouble: EXPECTED: january, february, march....december GOT: january, january, january.........january ------------- PROGRAMME -------------- /* Stroustrup, 5.9, exercise 10
0
9643
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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
10147
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...
0
9947
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
8971
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
5380
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...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4046
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
2
3645
muto222
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.