diff --git a/cmdgen.c b/cmdgen.c index 5216e753..78ac274e 100644 --- a/cmdgen.c +++ b/cmdgen.c @@ -816,7 +816,7 @@ int main(int argc, char **argv) const ssh_keyalg *alg = find_pubkey_alg(ssh2alg); if (alg) bits = ssh_key_public_bits( - alg, make_ptrlen(ssh2blob->s, ssh2blob->len)); + alg, ptrlen_from_strbuf(ssh2blob)); else bits = -1; } else { diff --git a/misc.c b/misc.c index 18edfb80..f360eebb 100644 --- a/misc.c +++ b/misc.c @@ -1243,6 +1243,16 @@ ptrlen make_ptrlen(const void *ptr, size_t len) return pl; } +ptrlen ptrlen_from_asciz(const char *str) +{ + return make_ptrlen(str, strlen(str)); +} + +ptrlen ptrlen_from_strbuf(strbuf *sb) +{ + return make_ptrlen(sb->u, sb->len); +} + int ptrlen_eq_string(ptrlen pl, const char *str) { size_t len = strlen(str); diff --git a/misc.h b/misc.h index 968c3d5d..fd63b335 100644 --- a/misc.h +++ b/misc.h @@ -97,6 +97,8 @@ struct tm ltime(void); int nullstrcmp(const char *a, const char *b); ptrlen make_ptrlen(const void *ptr, size_t len); +ptrlen ptrlen_from_asciz(const char *str); +ptrlen ptrlen_from_strbuf(strbuf *sb); int ptrlen_eq_string(ptrlen pl, const char *str); char *mkstr(ptrlen pl); int string_length_for_printf(size_t); diff --git a/ssh2userauth.c b/ssh2userauth.c index 10a2d171..1d526d02 100644 --- a/ssh2userauth.c +++ b/ssh2userauth.c @@ -867,8 +867,8 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl) BinarySink_UPCAST(sigblob)); strbuf_free(sigdata); ssh2_userauth_add_sigblob( - s, s->pktout, make_ptrlen(pkblob->s, pkblob->len), - make_ptrlen(sigblob->s, sigblob->len)); + s, s->pktout, ptrlen_from_strbuf(pkblob), + ptrlen_from_strbuf(sigblob)); strbuf_free(pkblob); strbuf_free(sigblob); diff --git a/sshpubk.c b/sshpubk.c index 510eb585..309e634d 100644 --- a/sshpubk.c +++ b/sshpubk.c @@ -584,7 +584,7 @@ const ssh_keyalg *find_pubkey_alg_len(ptrlen name) const ssh_keyalg *find_pubkey_alg(const char *name) { - return find_pubkey_alg_len(make_ptrlen(name, strlen(name))); + return find_pubkey_alg_len(ptrlen_from_asciz(name)); } struct ssh2_userkey *ssh2_load_userkey(const Filename *filename, @@ -798,8 +798,8 @@ struct ssh2_userkey *ssh2_load_userkey(const Filename *filename, ret = snew(struct ssh2_userkey); ret->comment = comment; ret->key = ssh_key_new_priv( - alg, make_ptrlen(public_blob->u, public_blob->len), - make_ptrlen(private_blob->u, private_blob->len)); + alg, ptrlen_from_strbuf(public_blob), + ptrlen_from_strbuf(private_blob)); if (!ret->key) { sfree(ret); ret = NULL;