runner: Use slices.Clip instead of x[:len(x):len(x)]

Change-Id: Id199612195581abbd0132d80876ebf4a8dc027b4
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/84907
Commit-Queue: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/ssl/test/runner/conn.go b/ssl/test/runner/conn.go
index df64010..d9a1051 100644
--- a/ssl/test/runner/conn.go
+++ b/ssl/test/runner/conn.go
@@ -1278,7 +1278,7 @@
 		if c.config.Bugs.TrailingDataWithFinished && msgType == typeFinished {
 			// Add a 0 to the record. Note unused bytes in |data| may be owned by the
 			// caller, so we force a new allocation.
-			data = append(data[:len(data):len(data)], 0)
+			data = append(slices.Clip(data), 0)
 		}
 	}
 
diff --git a/ssl/test/runner/handshake_client.go b/ssl/test/runner/handshake_client.go
index 1c46108..7742182 100644
--- a/ssl/test/runner/handshake_client.go
+++ b/ssl/test/runner/handshake_client.go
@@ -225,7 +225,7 @@
 			appendToHello = typeClientKeyExchange
 		}
 		if appendToHello != 0 {
-			c.writeRecord(recordTypeHandshake, append(helloBytes[:len(helloBytes):len(helloBytes)], appendToHello))
+			c.writeRecord(recordTypeHandshake, append(slices.Clip(helloBytes), appendToHello))
 		} else {
 			c.writeRecord(recordTypeHandshake, helloBytes)
 		}
diff --git a/ssl/test/runner/handshake_server.go b/ssl/test/runner/handshake_server.go
index 4e6ae98..731404a 100644
--- a/ssl/test/runner/handshake_server.go
+++ b/ssl/test/runner/handshake_server.go
@@ -794,7 +794,7 @@
 		hs.writeServerHash(helloRetryRequest.marshal())
 		if c.config.Bugs.PartialServerHelloWithHelloRetryRequest {
 			data := helloRetryRequest.marshal()
-			c.writeRecord(recordTypeHandshake, append(data[:len(data):len(data)], typeServerHello))
+			c.writeRecord(recordTypeHandshake, append(slices.Clip(data), typeServerHello))
 		} else {
 			c.writeRecord(recordTypeHandshake, helloRetryRequest.marshal())
 		}
@@ -1100,7 +1100,7 @@
 		helloBytes = helloBytes[1:]
 	}
 	if config.Bugs.PartialEncryptedExtensionsWithServerHello {
-		c.writeRecord(recordTypeHandshake, append(helloBytes[:len(helloBytes):len(helloBytes)], typeEncryptedExtensions))
+		c.writeRecord(recordTypeHandshake, append(slices.Clip(helloBytes), typeEncryptedExtensions))
 	} else {
 		c.writeRecord(recordTypeHandshake, helloBytes)
 	}
@@ -2034,7 +2034,7 @@
 		toAppend = typeFinished
 	}
 	if toAppend != 0 {
-		c.writeRecord(recordTypeHandshake, append(helloDoneBytes[:len(helloDoneBytes):len(helloDoneBytes)], toAppend))
+		c.writeRecord(recordTypeHandshake, append(slices.Clip(helloDoneBytes), toAppend))
 	} else {
 		c.writeRecord(recordTypeHandshake, helloDoneBytes)
 	}