From 8767ee3e24b2d1d23725b96118bae5722a869ad2 Mon Sep 17 00:00:00 2001
From: David Elliott <dfe@infinite-internet.net>
Date: Tue, 9 Jan 2001 20:52:53 +0000
Subject: [PATCH] Fixed usage of RegEnumValueA.

---
 dlls/winaspi/aspi.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/dlls/winaspi/aspi.c b/dlls/winaspi/aspi.c
index 57b74ace6a0..75dfd441357 100644
--- a/dlls/winaspi/aspi.c
+++ b/dlls/winaspi/aspi.c
@@ -459,7 +459,7 @@ SCSI_MapHCtoController()
 	DWORD disposition;
 
 	char idstr[20];
-	DWORD cbIdStr = 20;
+	DWORD cbIdStr;
 	int i = 0;
 	DWORD type = 0;
 	DWORD error;
@@ -487,9 +487,15 @@ SCSI_MapHCtoController()
 		return;
 	}
 	
-	for( i=0; (error=RegEnumValueA( hkeyScsi, i, idstr, &cbIdStr, NULL, &type, NULL, NULL )) == ERROR_SUCCESS; i++ )
+	for( i=0; cbIdStr = sizeof(idstr), (error=RegEnumValueA( hkeyScsi, i, idstr, &cbIdStr, NULL, &type, NULL, NULL )) == ERROR_SUCCESS; i++ )
 	{
-		sscanf(idstr, "h%02dc%02dt%*02dd%*02d", &ha, &chan);
+	        if(idstr[0] == '\0') continue; /* skip the default value */
+
+		if(sscanf(idstr, "h%02dc%02dt%*02dd%*02d", &ha, &chan) != 2) {
+			ERR("incorrect reg. value %s\n", debugstr_a(idstr));
+			continue;
+		}
+
 		if( last_ha < ha )
 		{	/* Next HA */
 			last_ha = ha;
-- 
GitLab