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


Closed Thread
  Search this Thread
Old 11-01-2001, 02:16 PM   #1
iam3
LQ Newbie
 
Registered: Oct 2001
Posts: 5

Rep: Reputation: 0
Unhappy a student


I know nothing about C++...got this exercise in a course about security...have been trying to understand this problem for last 3 hours...still in vain...can someone give me a hint??

#include <iostream>

main()
{
char command[40]; // Send command to
int time_of_day; // Avoid replay attack?
const bool ever = 1;

for ( ;ever; )
{
cin >> time_of_day >> command;
cout << "Command was " << command << " at time " << time_of_day << endl;
}
}

if we try input:
13 report
13 shoot-to-kill
15 shoot only if they shoot first
12:00 fire


how can someone perform a denial of service attack on this server? This same error was present in NT4, prior to service pack 2. This problem is difficult to fix with the C++ stream library, but easy to fix with C's I/O library:
#include <stdio.h>

#define ever 1

main()

{ char command[40]; // Send command to
int time_of_day; // Avoid replay attack?

for ( ;ever; )
{
scanf("%d %[^\n]",&time_of_day,command);
printf("Command %s at time %d\n",command,time_of_day);
}
}


The regular expression matcher %[^\n] means `match any object consisting of any character up to end of line'.
Why is it safer now?
 
Old 11-01-2001, 05:51 PM   #2
isajera
Senior Member
 
Registered: Jun 2001
Posts: 1,635

Rep: Reputation: 45
this thread is also in the programming forum. http://www.linuxquestions.org/questi...&threadid=8200
please post anything further on that thread. we forgive you this time, but in the future, please don't double post
 
  


Closed Thread


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
A student that needs help!!! smithers_3 Linux - General 6 05-27-2005 04:00 PM
College Student Gorkhali LinuxQuestions.org Member Intro 2 02-05-2005 07:06 AM
Student Studies engnet Linux - Software 1 12-05-2004 03:09 PM
Little Help with a student... Crowe182 Linux - Newbie 1 08-16-2003 09:58 PM
a student iam3 Programming 1 11-01-2001 05:43 PM

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

All times are GMT -5. The time now is 07:17 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration