Преглед изворни кода

Shell: Validate only one directory is given to cd

Shannon Booth пре 5 година
родитељ
комит
0de2ead0e9
1 измењених фајлова са 5 додато и 0 уклоњено
  1. 5 0
      Shell/main.cpp

+ 5 - 0
Shell/main.cpp

@@ -187,6 +187,11 @@ static String expand_tilde(const char* expression)
 
 static int sh_cd(int argc, const char** argv)
 {
+    if (argc > 2) {
+        fprintf(stderr, "cd: too many arguments\n");
+        return 1;
+    }
+
     String new_path;
 
     if (argc == 1) {