LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-03-2016, 06:00 AM   #1
micflunu
Member
 
Registered: Oct 2012
Posts: 73

Rep: Reputation: Disabled
what is the name of the attack??


int a[10];


extern int *a;

what is the problem in using this??What is the attack that is generated out of these??
 
Old 11-03-2016, 06:04 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,692

Rep: Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274
insufficient information, two lines of code cannot be attacked. Probably only by an eraser.
 
Old 11-03-2016, 06:19 AM   #3
micflunu
Member
 
Registered: Oct 2012
Posts: 73

Original Poster
Rep: Reputation: Disabled
NO it is an assignment i just am supposed to name the uncontrolled or un expected result that could come out of using pointers the same as arrays??
 
Old 11-03-2016, 09:25 AM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
why don't you fire up a text editior type out that code

Code:
int main (){

int a[10];
extern int *a;

for i=0;i<11;i++;
cout>>a[i];

cout>>&a
}
or how ever it would go, then see what your results are.
 
Old 11-03-2016, 09:00 PM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by micflunu View Post
int a[10];


extern int *a;

what is the problem in using this??What is the attack that is generated out of these??
As others have said, there isn't quite enough information. One thing missing is the language used... The example code given in a previous response should be invalid for C++, and IS invalid for C.

But what is likely is that the first declaration is in one module/file, and the second declaration is in a different module/file/function...

What is lost is the size of the array. For the first declaration you can get that information from the compiler using a "sizeof(a)", and it will give the number of bytes in an int (4) multiplied by the number of elements in the array (10), for size of 40 bytes.

In the second declaration "sizeof(a)" will give the size of a pointer... On 32 bit machines that will be 4, on a 64 bit machine that will be 8.

Not the same thing at all.

The problems this usually causes is an out of bounds error IF the module/function is not informed at runtime how large the array is.

Last edited by jpollard; 11-03-2016 at 09:02 PM.
 
1 members found this post helpful.
Old 11-03-2016, 09:40 PM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,610
Blog Entries: 4

Rep: Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905
Clearly, it is inappropriate to use the label, "attack." In this case, the proper label is simply, "bug!"

Quote:
It is an assignment. I just am supposed to name the uncontrolled or unexpected result that could come out of using pointers the same as arrays.
The two declarations, first of all, "are fundamentally different." (Hence, they would not and in fact cannot(!) be used together.) So, the locus of the question-at-hand really is: "what bugs might occur if the second declaration were used by the programmer, versus the first?"

Remember that the "C" language is purposely designed(!) "to be permissive." It always assumes that you know what you are doing. Therefore, it purposely allows "array-dereference" syntax to be applied to "pointers," and so-on.

This question is therefore challenging you, first and foremost, to understand(!) the difference between the two declarations, and then to comment on the "gotchas" that might arise from the simple fact that, "in C, the syntax might be the same."

So, now, "as the writer of the assignment intended for you to do," contemplate what I have just said.

(Because, if someday in some future job you are "hip-waders deep in 253,000 lines of mission-critical C-code that was first written 35 years ago ..." [and this most-certainly can happen] "... you will thank me.") (No, it is not too late to change majors ...)

---
"Who, me?" A sometimes community-college instructor? "Who, me?"

Last edited by sundialsvcs; 11-03-2016 at 09:44 PM.
 
1 members found this post helpful.
Old 11-04-2016, 06:01 AM   #7
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by sundialsvcs View Post
(No, it is not too late to change majors ...)

---
"Who, me?" A sometimes community-college instructor? "Who, me?"
chuckle chuckle

Maybe changes to java script thinking it is a (easier) programming lang. (bad joke)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Detection and Prevention of Blackhole Attack, Wormhole Attack in MANET Using ACO in ns2 neda_71 Linux - Software 5 08-13-2016 02:43 PM
Detection and Prevention of Blackhole Attack, Wormhole Attack in MANET Using ACO in ns2 neda_71 Linux - Virtualization and Cloud 1 07-30-2016 06:15 AM
[SOLVED] simulating blackhole attack and wormhole attack in ns-2 aditijigyasi Linux - Newbie 7 07-04-2016 08:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration