Skip to contentSkip to conversation

ssh: Remove unnecessary use of strlen function.

PATCH Applied Richard W.M. Jones 4 participants 4 messages Apr 18, 2013 – Apr 19, 2013 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ssh: Remove unnecessary use of strlen function.

From: "Richard W.M. Jones" <[email protected]>

---
 block/ssh.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
block/ssh.c +2 -4
index 8f78e2e..7bc008d 100644
@@ -387,15 +387,13 @@ static int check_host_key(BDRVSSHState *s, const char *host, int port,
     }
 
     /* host_key_check=md5:xx:yy:zz:... */
-    if (strlen(host_key_check) >= 4 &&
-        strncmp(host_key_check, "md5:", 4) == 0) {
+    if (strncmp(host_key_check, "md5:", 4) == 0) {
         return check_host_key_hash(s, &host_key_check[4],
                                    LIBSSH2_HOSTKEY_HASH_MD5, 16);
     }
 
     /* host_key_check=sha1:xx:yy:zz:... */
-    if (strlen(host_key_check) >= 5 &&
-        strncmp(host_key_check, "sha1:", 5) == 0) {
+    if (strncmp(host_key_check, "sha1:", 5) == 0) {
         return check_host_key_hash(s, &host_key_check[5],
                                    LIBSSH2_HOSTKEY_HASH_SHA1, 20);
     }
Signature · 1 line
1.8.1.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Richard W.M. Jones

From: "Richard W.M. Jones" <[email protected]>

---
 block/ssh.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Reviewed-by on v1 1/1
#2 lore raw
In reply to Richard W.M. Jones

Am 18.04.2013 23:09, schrieb Richard W.M. Jones:

Quoted 18 lines

From: "Richard W.M. Jones" <[email protected]>

---
 block/ssh.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
block/ssh.c +1 -2
index 8f78e2e..7bc008d 100644
@@ -387,15 +387,13 @@ static int check_host_key(BDRVSSHState *s, const char *host, int port,
     }
 
     /* host_key_check=md5:xx:yy:zz:... */
-    if (strlen(host_key_check) >= 4 &&
-        strncmp(host_key_check, "md5:", 4) == 0) {
+    if (strncmp(host_key_check, "md5:", 4) == 0) {
         return check_host_key_hash(s, &host_key_check[4],

block/ssh.c static int check_host_key(BDRVSSHState *s, const char *host, int port, · line 399

Quoted 10 lines
block/ssh.c +1 -2
                                    LIBSSH2_HOSTKEY_HASH_MD5, 16);
     }
 
     /* host_key_check=sha1:xx:yy:zz:... */
-    if (strlen(host_key_check) >= 5 &&
-        strncmp(host_key_check, "sha1:", 5) == 0) {
+    if (strncmp(host_key_check, "sha1:", 5) == 0) {
         return check_host_key_hash(s, &host_key_check[5],
                                    LIBSSH2_HOSTKEY_HASH_SHA1, 20);
     }