473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Buffer overflow error

I hv given below the code snippet
my static analyser tool gives an error message
"Buffer overflow, array index of 'old_name' may be outside the bounds. Array 'old_name' of size 64 declared at line 677 may use index values 0..83 "

class file1
{
publlic:
boolean open(const char* name);
private:
FILE *fh;
}

Boolean file1::open(const char* name)
{
if((fh = fopen(name, "r+")) != 0)
{
// do something here
return TRUE;
}
return FALSE;
}

main()
{
char old_name[64];
file1 w ;
if( w.open(old_name) )
{
do something here
}

Any insight on this would be appreciated
Thanks in advance
Dec 9 '08 #1
4 1490
JosAH
11,448 Expert 8TB
There is no valid file name stored in array old_name.

kind regards,

Jos
Dec 9 '08 #2
Banfa
9,065 Expert Mod 8TB
Also main should return int (although that wont be creating this error)
Dec 9 '08 #3
whodgson
542 512MB
I think you need a ; after the closing class bracket
Dec 19 '08 #4
Ganon11
3,652 Expert 2GB
whodgson, Banfa, and JosAH are all correct. You can't try to open that garbage - you have no idea what bogus values are in the memory location until you set it yourself. Better get a filename in there, or at least make sure it's null-terminated by the 64th character.
Dec 19 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: j-marvin | last post by:
hi- i am using the abyss webserver at the moment. i went through the process of how a buffer overflow would work in my mind. i noticed you can limit the size of post data and its limit value is...
3
by: David Sworder | last post by:
Hi there, I come from a Visual C++ background. When writing a service that's exposed to the Internet, I had to check the incoming data stream (from the client) VERY carefully. If a hacker was...
2
by: Tim::.. | last post by:
Hi... I have a major problem with a web application I am about to launch and just can't find out what the problem is... I believe it might be a Buffer Overflow problem but can't pin point the...
2
by: jay | last post by:
I am attempting to impersonate an account in ASPNET. I am using aspnet_setreg to store the username and passwords. I have given the ASPNET account permisision to read the registry values. However,...
5
by: Tim | last post by:
Hi, I'm experiencing some problem with the following code: st = File.Open(sFilename, FileMode.Open, FileAccess.ReadWrite) br = New BinaryReader(st) Do Until br.PeekChar = -1 Dim buffer()...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
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,...
0
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...

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.