如果密码为空 写一个字节 弥补String Copy的问题

This commit is contained in:
WangQiang 2016-07-27 09:52:55 +00:00
parent 6491bca78c
commit c9711f2d93
2 changed files with 6 additions and 1 deletions

View File

@ -1010,6 +1010,7 @@ bool Esp8266::SetWiFi(const BinaryPair& args, Stream& result)
if (!args.Get("ssid", ssid)) return false;
if (!args.Get("pass", pass)) // 获取失败 直接给0的长度
{
pass.Clear();
pass.SetLength(0);
// return false;
}

View File

@ -109,7 +109,11 @@ bool ISocketHost::SaveConfig()
nc.Gateway = Gateway.Value;
if(SSID) SSID->CopyTo(0, nc.SSID, ArrayLength(nc.SSID) - 1);
if(Pass) Pass->CopyTo(0, nc.Pass, ArrayLength(nc.Pass) - 1);
if (Pass)
{
Pass->CopyTo(0, nc.Pass, ArrayLength(nc.Pass) - 1);
if (Pass->Length() == 0)nc.Pass[0] = 0x00; // 如果密码为空 写一个字节 弥补String Copy的问题
}
Buffer bs(&nc, sizeof(nc));
return Config::Current->Set("NET", bs);