Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Ar/CSVFileLib/ANSIC.lby
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<?AutomationStudio FileVersion="4.9"?>
<Library Version="2.0.0" SubType="ANSIC" xmlns="http://br-automation.co.at/AS/Library">
<Library Version="2.0.1" SubType="ANSIC" xmlns="http://br-automation.co.at/AS/Library">
<Files>
<File Description="Exported data types">CSVFileLib.typ</File>
<File Description="Exported constants">CSVFileLib.var</File>
Expand Down
5 changes: 5 additions & 0 deletions src/Ar/CSVFileLib/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2.0.1 - Fix page fault when the file being read is larger than IN.CFG.MaxFileSize
Read buffers now allocate one extra byte so a completely full buffer is still a
valid string, and CSV_ST_OPEN reports CSV_ERR_BUFFERFULL instead of parsing a
truncated file

2.0.0 - Migrate to Automation Studio 6

1.2.5 - Fix critical bug introduced in 1.2.4
Expand Down
21 changes: 21 additions & 0 deletions src/Ar/CSVFileLib/CSVFn_Cyclic.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,27 @@ switch( t->OUT.STAT.State ){

t->Internal.FIOWrap.IN.CMD.Open= 0;


/* The file did not fit in the read buffer. FIOWrap passes IN.PAR.len straight
to FileRead, so the buffer is filled completely and the data is truncated
mid-file. Do not parse it. */

if( t->Internal.FIOWrap.OUT.STAT.FileLen > t->Internal.ReadBuffer.MaxLength ){

csvSetError( (UINT)CSV_ERR_BUFFERFULL, t );

break;

}


/* Record how much was actually read and terminate the buffer for parsing */

t->Internal.ReadBuffer.CurrentLength= t->Internal.FIOWrap.OUT.STAT.FileLen;

*(char*)(t->Internal.ReadBuffer.pData + t->Internal.ReadBuffer.CurrentLength)= '\0';


t->Internal.LineNumber= 0;

t->Internal.SuccessfulLineCount= 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Ar/CSVFileLib/csvClearBuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if( pBuffer == 0 ){

pBuffer->CurrentLength= 0;

memset( (void*)pBuffer->pData, 0, pBuffer->MaxLength );
memset( (void*)pBuffer->pData, 0, pBuffer->MaxLength + 1 );

return 0;

Expand Down
5 changes: 4 additions & 1 deletion src/Ar/CSVFileLib/csvInitBuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ if( (BufferLength == 0)

memset( pBuffer, 0, sizeof(CSVFileMgr_Int_Buffer_typ) );

if( TMP_alloc( BufferLength, (void **)&(pBuffer->pData) ) != 0 ) return CSV_ERR_MEMALLOC;
/* Allocate one extra byte so that a completely full buffer is still a valid C string.
MaxLength stays at BufferLength, so all overflow checks remain unchanged. */

if( TMP_alloc( BufferLength + 1, (void **)&(pBuffer->pData) ) != 0 ) return CSV_ERR_MEMALLOC;

pBuffer->MaxLength= BufferLength;

Expand Down
Loading