AOSC-Archive / Anthon-Starter

Installation helper for AOSC OSes.
https://portal.anthonos.org/ast
GNU General Public License v2.0
5 stars 2 forks source link

Improper matching rules in deploy_edit_ntldr #17

Closed jyhi closed 9 years ago

jyhi commented 9 years ago

In procedure deploy_edit_ntldr, we have implemented a BOOT.INI modification method.

if (_tcsstr (lineBuf, "timeout") != NULL)
if (_tcsstr (lineBuf, "default") != NULL)

Recently I am aware that this method can ONLY recognize lowercase letters. That means, when uppercase letters exist, this method can be invalid.

Need a better solution. Maybe we should use Regular Expression? Or other better solution?

m13253 commented 9 years ago

if (_tcsstr (lineBuf, "timeout") != NULL) if (_tcsstr (lineBuf, "default") != NULL)

These two lines does not compile when UNICODE and _UNICODE is set (which is default for latest Visual Studio). Wrap your string literals with _T().

m13253 commented 9 years ago

Recently I am aware that this method can ONLY recognize lowercase letters. That means, when uppercase letters exist, this method can be invalid.

Convert lineBuf to lowercase before comparing.

m13253 commented 9 years ago

Since you are reading and writing a INI file. Why aren't you using Windows API to parse such a file?

jyhi commented 9 years ago

@m13253

if (_tcsstr (lineBuf, "timeout") != NULL) if (_tcsstr (lineBuf, "default") != NULL)

These two lines does not compile when UNICODE and _UNICODE is set (which is default for latest Visual Studio). Wrap your string literals with _T().

  • [X] Will fix soon. (Fixed in 6345aee)

Convert lineBuf to lowercase before comparing.

Good Idea. Will fix soon.

Since you are reading and writing a INI file. Why aren't you using Windows API to parse such a file?

You mean GetPrivateProfileString and WritePrivateProfileString? There says, "calls to profile functions may be mapped to the registry instead of to the initialization files".

m13253 commented 9 years ago

You mean GetPrivateProfileString and WritePrivateProfileString? There says, "calls to profile functions may be mapped to the registry instead of to the initialization files".

Okay... I was wrong.

I googled and found that Qt contains a INI parser. There are also some lightweight INI parser library in C such as inih: https://stackoverflow.com/questions/12633/what-is-the-easiest-way-to-parse-an-ini-file-in-c

But since this is a fairly simple INI. String searching and replacing should work.