Fixed crash in fed when UTF-8 sequence crossed a block boundary.
authorTom Sutcliffe <thomas.sutcliffe@accenture.com>
Tue, 28 Sep 2010 17:03:08 +0100
changeset 64 72ffa331d78d
parent 63 6a2083f7eeb8
child 65 91da8db1df45
Fixed crash in fed when UTF-8 sequence crossed a block boundary. Also: * Cleaned up output of drvinfo * Fixed tefcons when no console-title argument was specified * Added FSHELL_INCLUDE_TESTS rombuild macro
build/common/fshell.iby
commands/drvinfo/drvinfo.cpp
commands/fed/src/filebuffer.cpp
core/builtins/ls.cif
core/docs/persistent_consoles.pod
core/group/fshell_core.iby
documentation/change_history.pod
plugins/consoles/tefcons/tefcons.cpp
--- a/build/common/fshell.iby	Mon Sep 20 16:46:34 2010 +0100
+++ b/build/common/fshell.iby	Tue Sep 28 17:03:08 2010 +0100
@@ -49,4 +49,8 @@
 FSHELL_EXECUTABLE_FILE(terminalkeyboardcons.dll) // TODO move this to the new fshell_consoles.iby
 #endif
 
+#ifdef FSHELL_TESTEXECUTE_SUPPORT
+FSHELL_EXECUTABLE_FILE(tefcons.dll) // TODO move this to the new fshell_consoles.iby
+#endif
+
 #endif // FSHELL_IBY
--- a/commands/drvinfo/drvinfo.cpp	Mon Sep 20 16:46:34 2010 +0100
+++ b/commands/drvinfo/drvinfo.cpp	Tue Sep 28 17:03:08 2010 +0100
@@ -155,20 +155,19 @@
 		}
 	if (iVerbose)
 		{
-		aPrintBuf.AppendFormatL(_L("VolName:\t\'%S\'"), &volInfo.iName);
+		aPrintBuf.AppendFormatL(_L("VolName:\t\'%S\'\r\n"), &volInfo.iName);
 		}
-	aPrintBuf.AppendL(_L("\r\n"));
 	}
 
 void CCmdDrvinfo::PrintDriveInfoL(TInt aDriveNum)
 	{
 	IoUtils::CTextBuffer* buf = IoUtils::CTextBuffer::NewLC(0x100);
 
-	TDriveInfo 	driveInfo;
+	TDriveInfo driveInfo;
 	User::LeaveIfError(FsL().Drive(driveInfo, aDriveNum));
 
 	TVolumeInfo volInfo;
-	User::LeaveIfError(Fs().Volume(volInfo, aDriveNum));
+	TInt volErr = Fs().Volume(volInfo, aDriveNum);
 
 	if (iVerbose || (iDriveLetter == NULL))
 		{
@@ -191,7 +190,7 @@
 		FormatMediaAttInfoL(driveInfo, *buf);
 		}
 
-	FormatVolInfoL(volInfo, *buf);
+	if (volErr == KErrNone) FormatVolInfoL(volInfo, *buf);
 
 	CTextFormatter* formatter = CTextFormatter::NewLC(Stdout());
 	formatter->TabulateL(0, 2, buf->Descriptor());
--- a/commands/fed/src/filebuffer.cpp	Mon Sep 20 16:46:34 2010 +0100
+++ b/commands/fed/src/filebuffer.cpp	Tue Sep 28 17:03:08 2010 +0100
@@ -852,7 +852,7 @@
 				{
 				// Can be null if charconv is busted
 				bytesLeft = aCharconvForUtf8Conversion->ConvertToUnicode(iData, data, state, numUnconverted, firstUnconverted);
-				ASSERT(bytesLeft <= 0); // Otherwise we didn't make our buffer big enough
+				ASSERT(bytesLeft <= 3); // Otherwise we didn't make our buffer big enough. There could be up to 3 bytes remaining if the block ends in a truncated UTF-8 sequence
 				// bytesLeft less than zero means an invalid sequence at the start of the buffer. Since our block size will never be so small there's no risk it's the start of a truncated sequence
 				}
 
@@ -865,16 +865,16 @@
 			else if (firstUnconverted >= 0)
 				{
 				// Got some bad data
-				if (iNext && data.Length() - firstUnconverted < 4)
+				if (iNext && data.Length() - bytesLeft < 4 && firstUnconverted == data.Length() - bytesLeft)
 					{
 					// Possibly a UTF-8 sequence spread over a block boundary
 					blockEncoding = EEncodingUtf8;
-					TInt err = iNext->TransferDataFromPreviousBlock(this, data.Mid(firstUnconverted));
+					TInt err = iNext->TransferDataFromPreviousBlock(this, data.Right(bytesLeft));
 					if (!err)
 						{
-						iBlockSize = firstUnconverted;
+						iBlockSize -= bytesLeft;
 						}
-					iData.SetLength(iData.Locate(0xFFFD)); // No better way of figuring out where charconv barfed than to scan for the first instance of the substitution character
+					iData.SetLength(iData.LocateReverse(0xFFFD)); // No better way of figuring out where charconv barfed than to scan for the last instance of the substitution character
 					}
 				else
 					{
--- a/core/builtins/ls.cif	Mon Sep 20 16:46:34 2010 +0100
+++ b/core/builtins/ls.cif	Tue Sep 28 17:03:08 2010 +0100
@@ -58,7 +58,7 @@
 
 =back
 
-For example, C<d--s-> indicates a drectory with the system bit set.
+For example, C<d--s-> indicates a directory with the system bit set.
 
 ==option bool H human
 
--- a/core/docs/persistent_consoles.pod	Mon Sep 20 16:46:34 2010 +0100
+++ b/core/docs/persistent_consoles.pod	Tue Sep 28 17:03:08 2010 +0100
@@ -79,7 +79,7 @@
 	my pcons      fshell::pcons_00  -       -
 	fshell_pcons  fshell(2)         -       -
 
-This equivilant to typing C<pcons new fshell_pcons>.
+This equivalent to typing C<pcons new fshell_pcons>.
 
 You can also specify a process to launch when using C<pcons new> by specifying a command and arguments after the console name. For example,
 
--- a/core/group/fshell_core.iby	Mon Sep 20 16:46:34 2010 +0100
+++ b/core/group/fshell_core.iby	Tue Sep 28 17:03:08 2010 +0100
@@ -189,4 +189,29 @@
 FSHELL_DATA_FILE(ZSYSTEM\perl\lib\Fshell\TextServerClient.pm, system\perl\lib\Fshell\TextServerClient.pm)
 #endif
 
+#ifdef FSHELL_INCLUDE_TESTS
+FSHELL_DATA_FILE(ZSYSTEM\console\scripts\args.script, system\console\scripts\args.script)
+FSHELL_DATA_FILE(ZSYSTEM\console\scripts\checkargs.script, system\console\scripts\checkargs.script)
+FSHELL_DATA_FILE(ZSYSTEM\console\scripts\setenv.script, system\console\scripts\setenv.script)
+FSHELL_DATA_FILE(ZSYSTEM\console\scripts\addenv.script, system\console\scripts\addenv.script)
+FSHELL_DATA_FILE(ZSYSTEM\console\scripts\printerror.script, system\console\scripts\printerror.script)
+FSHELL_DATA_FILE(ZSYSTEM\console\scripts\fshell-basic-test.script, system\console\scripts\fshell-basic-test.script)
+FSHELL_DATA_FILE(ZSYSTEM\console\scripts\fshell-last-test.script, system\console\scripts\fshell-last-test.script)
+FSHELL_DATA_FILE(ZSYSTEM\console\scripts\fshell-ccommandbase-test.script, system\console\scripts\fshell-ccommandbase-test.script)
+FSHELL_DATA_FILE(ZSYSTEM\console\scripts\fshell-unicode-test.script, system\console\scripts\fshell-unicode-test.script)
+FSHELL_DATA_FILE(ZSYSTEM\console\scripts\fshell-scriptcif-test.script, system\console\scripts\fshell-scriptcif-test.script)
+FSHELL_DATA_FILE(ZSYSTEM\console\scripts\smoketest.script, system\console\scripts\smoketest.script)
+FSHELL_DATA_FILE(ZSYSTEM\console\scripts\tscriptargs.script, system\console\scripts\tscriptargs.script)
+FSHELL_DATA_FILE(ZSYSTEM\console\scripts\tlotsofscriptargs.script, system\console\scripts\tlotsofscriptargs.script)
+FSHELL_DATA_FILE(ZSYSTEM\console\scripts\errordef.script, system\console\scripts\errordef.script)
+FSHELL_COMMAND_INFO_FILE(fshell,tenvarguments.cif)
+
+FSHELL_EXECUTABLE_FILE(tlast.exe)
+FSHELL_EXECUTABLE_FILE(tconsole.exe)
+FSHELL_EXECUTABLE_FILE(tinteger.exe)
+FSHELL_EXECUTABLE_FILE(tfshellarguments.exe)
+FSHELL_EXECUTABLE_FILE(tenvarguments.exe)
+FSHELL_EXECUTABLE_FILE(tnoncifenvarguments.exe)
 #endif
+
+#endif
--- a/documentation/change_history.pod	Mon Sep 20 16:46:34 2010 +0100
+++ b/documentation/change_history.pod	Tue Sep 28 17:03:08 2010 +0100
@@ -20,6 +20,10 @@
 
 =item *
 
+Fixed crash in fed's handling of UTF-8 sequences split over a block boundary.
+
+=item *
+
 Added support for automatically starting a USB personality to vt100usbcons via a new C<personality=x> key-value pair. See the L<vt100usbcons|vt100cons/usb variant> documentation for more information.
 
 =back
--- a/plugins/consoles/tefcons/tefcons.cpp	Mon Sep 20 16:46:34 2010 +0100
+++ b/plugins/consoles/tefcons/tefcons.cpp	Tue Sep 28 17:03:08 2010 +0100
@@ -47,6 +47,8 @@
 	{
 	}
 
+_LIT(KDefaultLog, "c:\\logs\\testexecute\\fshell.htm");
+
 TInt CTefConsole::Create(const TDesC& aTitle, TSize /*aSize*/)
 	{
 	iLogger = new CTestExecuteLogger();
@@ -56,7 +58,11 @@
 	iLogger->SetLoggerOptions(logMode);
 	TInt err = iLogger->Connect();
 	if (err) return err;
-	const TDesC& logFilePath(aTitle);
+	TPtrC logFilePath(KDefaultLog);
+	if (aTitle.Left(5) == _L("name="))
+		{
+		logFilePath.Set(aTitle.Mid(5));
+		}
 	err = iLogger->HtmlLogger().CreateLog(logFilePath, RTestExecuteLogServ::ELogModeAppend);
 	if (err) return err;
 	iLogger->HtmlLogger().SetLogLevel(TLogSeverity(logLevel));