Save
Busy. Please wait.
Log in with Clever
or

show password
Forgot Password?

Don't have an account?  Sign up 
Sign up using Clever
or

Username is available taken
show password


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
Your email address is only used to allow you to reset your password. See our Privacy Policy and Terms of Service.


Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.
focusNode
Didn't know it?
click below
 
Knew it?
click below
Don't Know
Remaining cards (0)
Know
0:00
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how

CYB2200 - LAB1

slides

QuestionAnswer
many software, programs, applications need to interact with people
what are some formats of input keyboard, mouse click, track pad, touchscreen, reading from files, receiving data from network ...
consider if your program takes user input... consider adversary thinking what could someone deliberately do to compromise your program
consider if your program takes user input ... consider that people make mistakes what could someone unintentionally do to compromise your program
what are some defensive programming input validation, type checking
what can be the source of vulnerability any program input (user input from keyboard, a file, a network connection)
what should all input be treated as potentially dangerous
input validation the process of checking whether user input conforms to what the program is expecting
what is the coders/code responsibility check your input, use appropriate tools and functions to get input, recover appropriately
to check your input what should you check type, range, length, format
input type input data should be of the right data type
input range within a range of possible values (the values make sense)
input length too long or too short
input format specific format? date, phone number, SSN
what is a way to use appropriate tools and functions to get input use safer functions to get input . ex never use gets() use fgets() or getchar() instead
never use what input function gets
gets() char* gets(char* str);
gets() function reads characters from stdin and stores them in str until a newline character or end of file is found
why is gets() dangerous for input it is impossible to tell without knowing the data in advance how many characters gets() will read, and because gets() will continue to store characters past the end of the buffer it is extremely dangerous to use
what are two alternative safer functions to gets() fgets() or getchar()
fgets() function char* fgets(char*str, int num, FILE*stream);
str in fgets() pointer to an array of chars where the string read is copied
num in fgets() maximum number of characters to be copied into str (including the terminating null-character)
stream in fgets() pointer to a FILE object that identifies an input stream (stdin can be used as argument to read from the standard input)
what does fgets() return if the read fails the function returns NULL
getchar() int getchar(void);
getchar() function returns the next character from standard input (stdin)
what happens using getchar() if the standard input was at the end of file the function returns EOF and sets the eof indicator (feof) of stdin
what happens using getchar() if some other reading error happens the function returns EOF but set its error indicator (ferror) instead
what are the pros of using getchar() have better control of what you are reading in
what do you need to check when using getchar() the boundary of the buffer
what are ways to recover appropriately have proper message to indicate problem, drop bad one&ask for a new one until getting a valid input (preferred way), parse it& make changes on input (drop certain characters/symbols),truncate it if input is too long, terminate prog (not a good choice)
Created by: user-1830624
Popular Computers sets

 

 



Voices

Use these flashcards to help memorize information. Look at the large card and try to recall what is on the other side. Then click the card to flip it. If you knew the answer, click the green Know box. Otherwise, click the red Don't know box.

When you've placed seven or more cards in the Don't know box, click "retry" to try those cards again.

If you've accidentally put the card in the wrong box, just click on the card to take it out of the box.

You can also use your keyboard to move the cards as follows:

If you are logged in to your account, this website will remember which cards you know and don't know so that they are in the same box the next time you log in.

When you need a break, try one of the other activities listed below the flashcards like Matching, Snowman, or Hungry Bug. Although it may feel like you're playing a game, your brain is still making more connections with the information to help you out.

To see how well you know the information, try the Quiz or Test activity.

Pass complete!
"Know" box contains:
Time elapsed:
Retries:
restart all cards