@@ -542,14 +542,23 @@ static DWORD LoadBuildNumber(TCascStorage * hs, const char * /* szVariableName *
542542 return ERROR_BAD_FORMAT;
543543}
544544
545- static int LoadQueryKey (const CASC_CSV_COLUMN & Column, CASC_BLOB & Key)
545+ static DWORD LoadQueryKey (const CASC_CSV_COLUMN & Column, CASC_BLOB & Key)
546546{
547- // Check the input data
548- if (Column.szValue == NULL )
549- return ERROR_BUFFER_OVERFLOW;
550- if (Column.nLength != MD5_STRING_SIZE)
547+ // Check for existence
548+ if (Column.Empty ())
549+ {
550+ Key.Free ();
551+ return ERROR_SUCCESS;
552+ }
553+
554+ // Check for invalid length
555+ if (Column.nLength && Column.nLength != MD5_STRING_SIZE)
556+ {
557+ assert (false );
551558 return ERROR_BAD_FORMAT;
559+ }
552560
561+ // Convert the text value into binary blob
553562 return LoadHashArray (&Key, Column.szValue , Column.szValue + Column.nLength , 1 );
554563}
555564
@@ -586,19 +595,24 @@ static DWORD GetDefaultLocaleByRegion(LPCSTR szRegion)
586595
587596static DWORD GetDefaultLocaleMask (const CASC_CSV_COLUMN & Column)
588597{
589- LPCSTR szTagEnd = Column.szValue + Column.nLength - 4 ;
590- LPCSTR szTagPtr;
591598 DWORD dwLocaleValue;
592599 DWORD dwLocaleMask = 0 ;
593600
594- // Go through the whole tag string
595- for (szTagPtr = Column.szValue ; szTagPtr <= szTagEnd; szTagPtr++ )
601+ // Check whether the column contains some data
602+ if (! Column.Empty () )
596603 {
597- // Try to recognize the 4-char locale code
598- if ((dwLocaleValue = GetLocaleValue (szTagPtr)) != CASC_LOCALE_NONE)
604+ LPCSTR szTagEnd = Column.szValue + Column.nLength - 4 ;
605+ LPCSTR szTagPtr;
606+
607+ // Go through the whole tag string
608+ for (szTagPtr = Column.szValue ; szTagPtr <= szTagEnd; szTagPtr++)
599609 {
600- dwLocaleMask |= dwLocaleValue;
601- szTagPtr += 3 ; // Will be moved by 1 more at the end of the loop
610+ // Try to recognize the 4-char locale code
611+ if ((dwLocaleValue = GetLocaleValue (szTagPtr)) != CASC_LOCALE_NONE)
612+ {
613+ dwLocaleMask |= dwLocaleValue;
614+ szTagPtr += 3 ; // Will be moved by 1 more at the end of the loop
615+ }
602616 }
603617 }
604618 return dwLocaleMask;
@@ -714,13 +728,13 @@ static DWORD ParseFile_BuildInfo(TCascStorage * hs, CASC_CSV & Csv)
714728
715729 // If we found version, extract a build number
716730 const CASC_CSV_COLUMN & VerColumn = Csv[nSelected][" Version!STRING:0" ];
717- if (VerColumn.szValue && VerColumn. nLength )
731+ if (! VerColumn.Empty () )
718732 {
719733 LoadBuildNumber (hs, NULL , VerColumn.szValue , VerColumn.szValue + VerColumn.nLength , NULL );
720734 }
721735
722- // Verify all variables
723- return ( hs->CdnBuildKey .pbData != NULL && hs-> CdnConfigKey . pbData != NULL ) ? ERROR_SUCCESS : ERROR_BAD_FORMAT;
736+ // At least the build key must be valid here
737+ return hs->CdnBuildKey .Valid ( ) ? ERROR_SUCCESS : ERROR_BAD_FORMAT;
724738 }
725739
726740 return ERROR_FILE_NOT_FOUND;
0 commit comments