• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

修订版7697f857cd5f7dcadae78aec84a228c3660124bc (tree)
时间2016-09-16 22:16:38
作者Christopher R. Palmer <crpalmer@gmai...>
CommiterChristopher R. Palmer

Log Message

init: Don't crash the system due to an invalid mkdir argument

Prior to this change, if someone write

mkdir /data/log/sar_cap system system

in one of their init.rc files, this causes init to get a exception
which causes init to exit with no error message to allow you to track
this down which then causes your kernel to panic.

Let's make this a little more user friendly by simply reporting
an error instead of silently crashing the whole damn system.

Change-Id: I2f8c50391e78a9992d33754cf1f1e34e9fcee047

更改概述

差异

--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -303,7 +303,12 @@ static int do_mkdir(const std::vector<std::string>& args) {
303303 /* mkdir <path> [mode] [owner] [group] */
304304
305305 if (args.size() >= 3) {
306- mode = std::stoul(args[2], 0, 8);
306+ unsigned long mode_ul;
307+ if (sscanf(args[2].c_str(), "%lo", &mode_ul) != 1) {
308+ ERROR("mkdir: invalid mode %s\n", args[2].c_str());
309+ return -EINVAL;
310+ }
311+ mode = (mode_t) mode_ul;
307312 }
308313
309314 ret = make_dir(args[1].c_str(), mode);