Purchase Solution

Buffer-overflow

Not what you're looking for?

Ask Custom Question

Buffer-overflow is a common computer security concern. Write a simple program, in C, C++, and Java, to declare a simple one dimensional array and then attempt to access an array element that is not within its bounds. For example, what happens if I declare an array to be in studentNums[10] and then attempt to access studentNums[11], studentNums[12], or ..., studentNums[100] ?

Purchase this Solution

Solution Preview

In C/C++ the system does allow accessing an array element that is not within its bounds.

For instance this C/C++ code:

#include <stdio.h>
#include <memory.h>
int main()
{
int studentNums[10] ;

memset ((void *)studentNums, 0x00, sizeof (studentNums)) ;

printf ("studentNums[9] = %dn", studentNums[9] ) ;

printf ("studentNums[10] = %dn", studentNums[10] ) ;

printf ("studentNums[11] = %dn", studentNums[11] ) ;

studentNums[11] = 11 ;

printf ("studentNums[11] = %dn", studentNums[11] ) ;

return 0;
}

outputs:

studentNums[9] = ...

Purchase this Solution


Free BrainMass Quizzes
Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Basic Networking Questions

This quiz consists of some basic networking questions.

Javscript Basics

Quiz on basics of javascript programming language.