mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 09:27:59 +00:00
New utility functions to make ptrlens.
One to make one from a NUL-terminated string, and another to make one from a strbuf. I've switched over all the obvious cases where I should have been using these functions.
This commit is contained in:
parent
b9bfc81531
commit
56096ba558
2
cmdgen.c
2
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 {
|
||||
|
10
misc.c
10
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);
|
||||
|
2
misc.h
2
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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user