QTextCodec: avoid read-past-buffer in codecForName()
The old code passed a QByteArray to a function taking const char*,
invoking QByteArray::operator const char*() implicitly.
The callee expects the argument to be NUL-terminated, but if the
QByteArray was created fromRawData(), that is not guaranteed.
In newer Qt versions we have nullTerminated(), but this needs to be
picked furthr back, so use a std::string to do the null-termination.
[ChangeLog][QTextCodec] Fixed an out-of-bounds read in codecForName().
which could read past the end of the QByteArray argument if the
argument was created fromRawData() with no NUL-termination.
Amends the start of the public history even in qtbase (where
nameMatch() took QByteArrays, yes, but then proceeded to qstricmp()
them, invoking said operator).
Pick-to: 6.11 6.10 6.8 6.5 5.15
Fixes: QTBUG-145180
Change-Id: If82adb1309993d125d807ffa47afc47229039343
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>