libnui / nui3

libnui v3

Home Page:http://libnui.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nglPath canonize bug

mathieugarcia opened this issue · comments

There is an issue with nglPath::Canonize, I'm currently investigating the issue.
This code will crash (nglString::Delete):

nglPath p(_T("../../a.txt"));
NGL_OUT(_T("p BEFORE: %s\n"), p.GetChars());
p.Canonize();
NGL_OUT(_T("p AFTER: %s\n"), p.GetChars());

This crash comes from nglPath::GetRootPath(), when trying to parse the volume name. It will try to find the position of ':' then '/', BUT, no error checking is done to the two nglPath::Find() calls. Then, statement if (col < slash) is true even if col is -1.

Here is the patch: https://gist.github.com/3019031