Commit f380336dbc7e08a105a7ef6e258f6b1f329bf91f

Con Kolivas 2014-01-04T11:56:59

Reword offset header handling in hfa_get_header

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/driver-hashfast.c b/driver-hashfast.c
index 9da4569..192ec45 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -179,8 +179,14 @@ static bool hfa_get_header(struct cgpu_info *hashfast, struct hf_header *h, uint
 			return false;
 		ofs += amount;
 		header = memchr(buf, HF_PREAMBLE, ofs);
-		if (header)
-			len -= ofs - (header - buf);
+		if (header) {
+			/* Toss any leading data we can't use */
+			if (header != buf) {
+				memmove(buf, header, ofs);
+				ofs -= header - buf;
+			}
+			len -= ofs;
+		}
 	} while (len > 0);
 
 	memcpy(h, header, orig_len);