Hi,
great! The fix below should be enough (not tested), but maybe we should
add a better error check for ads function return values...
Index: C:/harboursvn/contrib/rddads/ads1.c
===================================================================
--- C:/harboursvn/contrib/rddads/ads1.c (revision 11047)
+++ C:/harboursvn/contrib/rddads/ads1.c (working copy)
@@ -2054,14 +2054,6 @@
update area flags, Druzus */
hb_adsUpdateAreaFlags( pArea );
}
- /* workaround for ACE bug: character fields longer then 23
bytes are
- * increased by one byte when read by AdsGetField(). This hack can
- * cut the results read from some type of compressed fields so it
- * should be removed for ACE clients which does not have such
- * problems [druzus].
- */
- if( u32Length > ( ULONG ) pField->uiLen )
- u32Length = pField->uiLen;
hb_itemPutCL( pItem, ( char * ) pBuffer, u32Length );
break;
@@ -2707,8 +2699,8 @@
pField = pArea->lpFields;
for( uiCount = 0; uiCount < pArea->uiFieldCount; uiCount++ )
{
- if( ( ULONG ) pField->uiLen > pArea->maxFieldLen )
- pArea->maxFieldLen = pField->uiLen;
+ if( ( ULONG ) pField->uiLen + 1 > pArea->maxFieldLen )
+ pArea->maxFieldLen = pField->uiLen + 1;
cType = NULL;
switch( pField->uiType )
@@ -3196,9 +3188,9 @@
dbFieldInfo.uiLen = ( USHORT ) u32Length;
dbFieldInfo.uiDec = 0;
dbFieldInfo.uiFlags = 0;
- if( u32Length > pArea->maxFieldLen )
+ if( u32Length + 1 > pArea->maxFieldLen )
{
- pArea->maxFieldLen = u32Length;
+ pArea->maxFieldLen = u32Length + 1;
}
dbFieldInfo.uiTypeExtended = usType;
switch( usType )
Regards,
Mindaugas
toni...@fwi wrote:
Hi ppl.
I´d posted this message in Advantage.General:
---cut---
I´m a Harbour user and our group found a problem when use
AdsGetField(..., ADS_NONE): character fields longer then 23 bytes read
from tables increase pulLen by one adding one garbage character to the
end of string. Is this an expected behaviour ?
---cut---
and this is the answer:
---cut---
There is no specific length check involving 23 bytes. The parameters
passed to the AdsGetField function might not be correct. Was an error
returned from the call? If the call succeeds, it returns AE_SUCCESS
(0). If the buffer passed in is too short, it will return
AE_INSUFFICIENT_BUFFER (5005).
The buffer length that you pass in must include room for the null
terminator character. So, for example, if the data is 25 bytes, you
must pass a buffer of at least 26 bytes. If you pass a buffer of only
25 bytes (as specified by the pulLen parameter), then the function
will return AE_INSUFFICIENT_BUFFER and will not null-terminate the
result. It will copy all 25 bytes of the data into the result buffer.
This may be what you are seeing. Since there would be no null
terminator, it would appear that there is junk on the end of the
string.
http://devzone.advantagedatabase.com/dz/webhelp/Advantage9.1/mergedProjects/ace/api2/adsgetfield.htm
---cut---
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour