Skip to content

[Precogs Alert] Command Injection detected (CWE-78, Risk: High) #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions Lab_21/city_temperature_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ void CityRainFallInfo() {
CityRainFall R;

for (int i = 0; i < 1000; i++) {
system("cls");
// Clear the console using a safer method
cout << "\033[2J\033[1;1H"; // ANSI escape codes for clearing the screen

cout << "City RainFall Information: \n";
cout << "1. Add\n";
Expand All @@ -355,7 +356,7 @@ void CityRainFallInfo() {
switch (_getch())
{
case '1': {
system("cls");
cout << "\033[2J\033[1;1H"; // Clear screen
cout << "ADD DATA TO CITY\n";
cout << "Enter RainFall data of city: " << endl;
// Add to List
Expand All @@ -364,17 +365,19 @@ void CityRainFallInfo() {
outR.write((char*)&R, sizeof(CityRainFall));
outR.close();

system("pause");
cout << "Press any key to continue...";
cin.ignore();
cin.get();
}break;

case '2': {
system("cls");
cout << "\033[2J\033[1;1H"; // Clear screen

ifstream inP("R", ios::binary);
while (inP.read((char*)&R, sizeof(CityRainFall))) {
R.getClimateData();
}
inP.close(); // closing the files after execution
inP.close();

// searching the city by its ID
int ID;
Expand Down Expand Up @@ -412,19 +415,21 @@ void CityRainFallInfo() {
out.close();
cout << "\nSuccessfully updated" << endl;

system("pause");
cout << "Press any key to continue...";
cin.ignore();
cin.get();
}break;

case '3': {
system("cls");
cout << "\033[2J\033[1;1H"; // Clear screen

cout << "DELETING DATA FROM CITY\n";

ifstream inP("R", ios::binary);
while (inP.read((char*)&R, sizeof(CityRainFall))) {
R.getClimateData();
}
inP.close(); // closing the files after execution
inP.close();
// searching the city by its ID
int ID;
cout << "Enter ID of city which you want to delete: ";
Expand All @@ -450,9 +455,11 @@ void CityRainFallInfo() {
while (inP2.read((char*)&R, sizeof(CityRainFall))) {
R.getClimateData();
}
inP2.close(); // closing the files after execution
inP2.close();

system("pause");
cout << "Press any key to continue...";
cin.ignore();
cin.get();
}break;

case '0': {
Expand All @@ -462,14 +469,15 @@ void CityRainFallInfo() {

default: {
cout << "Your choice is not available in menu!\n";
system("pause");
cout << "Press any key to continue...";
cin.ignore();
cin.get();
}
break;
} // switch

} // for loop


}

void CityHumidityInfo() {
Expand Down