Suppose I wrote a simple program to take in a filename from a user and then, using that given filename my program would execute a command to copy that file to a particular location (such as my own submission directory). I then made that program executable by someone else. For example, if they gave me a filename "dog.txt", my program would create a string called "cp dog.txt subfolder" and then execute it using the system command. What would I need to do to ensure that nothing malicious was allowed to happen?

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question
Suppose I wrote a simple program to take in a filename from a user and then, using that given filename my program would execute a command to copy that file to a
particular location (such as my own submission directory). I then made that program executable by someone else.
For example, if they gave me a filename "dog.txt", my program would create a string called "cp dog.txt subfolder" and then execute it using the system command.
What would I need to do to ensure that nothing malicious was allowed to happen?
Transcribed Image Text:Suppose I wrote a simple program to take in a filename from a user and then, using that given filename my program would execute a command to copy that file to a particular location (such as my own submission directory). I then made that program executable by someone else. For example, if they gave me a filename "dog.txt", my program would create a string called "cp dog.txt subfolder" and then execute it using the system command. What would I need to do to ensure that nothing malicious was allowed to happen?
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT