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

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

All times are GMT -5. The time now is 03:16 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
Open Source Consulting | Domain Registration