Page 1 of 1

Suggestions for bug in VOLUMENAME function

Posted: Fri Apr 24, 2020 3:16 pm
by MaxP
Hello,

If the function GetVolumeInformation fails (harddisk.c), a random buffer is returned

Code: Select all

HB_FUNC( VOLUMENAME )
{
   DWORD dwVolumeSerialNumber;
   BYTE VolumeNameBuffer[ 256 ];
   BYTE FileSystemNameBuffer[ 256 ];
/*****
   GetVolumeInformation( hb_pcount() ? hb_parc( 1 ): "C:\\",
                         ( char * ) VolumeNameBuffer, sizeof( VolumeNameBuffer ),
                         &dwVolumeSerialNumber, 0, 0,
                         ( char * ) FileSystemNameBuffer,
                         sizeof( FileSystemNameBuffer ) ); */
/*****/
   if ( ! GetVolumeInformation( hb_pcount() ? hb_parc( 1 ): "C:\\",
                         ( char * ) VolumeNameBuffer, sizeof( VolumeNameBuffer ),
                         &dwVolumeSerialNumber, 0, 0,
                         ( char * ) FileSystemNameBuffer,
                         sizeof( FileSystemNameBuffer ) ) )
          VolumeNameBuffer[0] = '\0' ;            
/*****/

   hb_retc( ( char * ) VolumeNameBuffer );
}
Regards
Massimo