diff --git a/marshal.h b/marshal.h index bcd2b38d..20094289 100644 --- a/marshal.h +++ b/marshal.h @@ -141,6 +141,10 @@ struct BinarySink { BinarySink_put_data(BinarySink_UPCAST(bs), val, len) #define put_datapl(bs, pl) \ BinarySink_put_datapl(BinarySink_UPCAST(bs), pl) +#define put_dataz(bs, val) \ + BinarySink_put_datapl(BinarySink_UPCAST(bs), ptrlen_from_asciz(val)) +#define put_datalit(bs, val) \ + BinarySink_put_datapl(BinarySink_UPCAST(bs), PTRLEN_LITERAL(val)) /* Emit printf-formatted data, with no terminator. */ #define put_fmt(bs, ...) \ diff --git a/unix/plink.c b/unix/plink.c index 446bef21..385fe993 100644 --- a/unix/plink.c +++ b/unix/plink.c @@ -774,7 +774,7 @@ int main(int argc, char **argv) while (argc > 0) { if (cmdbuf->len > 0) put_byte(cmdbuf, ' '); /* add space separator */ - put_datapl(cmdbuf, ptrlen_from_asciz(p)); + put_dataz(cmdbuf, p); if (--argc > 0) p = *++argv; } diff --git a/unix/storage.c b/unix/storage.c index 7a9585f9..9132eb70 100644 --- a/unix/storage.c +++ b/unix/storage.c @@ -557,7 +557,7 @@ bool enum_settings_next(settings_e *handle, strbuf *out) fullpath = strbuf_new(); char *sessiondir = make_filename(INDEX_SESSIONDIR, NULL); - put_datapl(fullpath, ptrlen_from_asciz(sessiondir)); + put_dataz(fullpath, sessiondir); sfree(sessiondir); put_byte(fullpath, '/'); @@ -565,7 +565,7 @@ bool enum_settings_next(settings_e *handle, strbuf *out) while ( (de = readdir(handle->dp)) != NULL ) { strbuf_shrink_to(fullpath, baselen); - put_datapl(fullpath, ptrlen_from_asciz(de->d_name)); + put_dataz(fullpath, de->d_name); if (stat(fullpath->s, &st) < 0 || !S_ISREG(st.st_mode)) continue; /* try another one */ diff --git a/utils/antispoof.c b/utils/antispoof.c index b3a04ef3..6435944f 100644 --- a/utils/antispoof.c +++ b/utils/antispoof.c @@ -11,7 +11,7 @@ void seat_antispoof_msg(InteractionReadySeat iseat, const char *msg) * generated by the client, then we can just use the message * unmodified as an unspoofable header. */ - put_datapl(sb, ptrlen_from_asciz(msg)); + put_dataz(sb, msg); } else if (*msg) { /* * Otherwise, add enough padding around it that the server diff --git a/utils/prompts.c b/utils/prompts.c index e26ef905..e01dd01c 100644 --- a/utils/prompts.c +++ b/utils/prompts.c @@ -34,7 +34,7 @@ void add_prompt(prompts_t *p, char *promptstr, bool echo) void prompt_set_result(prompt_t *pr, const char *newstr) { strbuf_clear(pr->result); - put_datapl(pr->result, ptrlen_from_asciz(newstr)); + put_dataz(pr->result, newstr); } const char *prompt_get_result_ref(prompt_t *pr) diff --git a/windows/dialog.c b/windows/dialog.c index a5af31ed..b790f0f4 100644 --- a/windows/dialog.c +++ b/windows/dialog.c @@ -889,7 +889,7 @@ static INT_PTR CALLBACK HostKeyDialogProc(HWND hwnd, UINT msg, for (size_t i = 0; ctx->keywords[i]; i++) { if (strstartswith(p, ctx->keywords[i])) { p += strlen(ctx->keywords[i]); - put_datapl(sb, ptrlen_from_asciz(ctx->values[i])); + put_dataz(sb, ctx->values[i]); goto matched; } } diff --git a/windows/plink.c b/windows/plink.c index 8dc44c9e..037387e9 100644 --- a/windows/plink.c +++ b/windows/plink.c @@ -366,7 +366,7 @@ int main(int argc, char **argv) while (argc > 0) { if (cmdbuf->len > 0) put_byte(cmdbuf, ' '); /* add space separator */ - put_datapl(cmdbuf, ptrlen_from_asciz(p)); + put_dataz(cmdbuf, p); if (--argc > 0) p = *++argv; }