From 1547c9c1ec44077e4b9d1506e880820cbed8e319 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Mon, 14 Oct 2019 19:42:37 +0100 Subject: [PATCH] Make dupcat() into a variadic macro. Up until now, it's been a variadic _function_, whose argument list consists of 'const char *' ASCIZ strings to concatenate, terminated by one containing a null pointer. Now, that function is dupcat_fn(), and it's wrapped by a C99 variadic _macro_ called dupcat(), which automatically suffixes the null-pointer terminating argument. This has three benefits. Firstly, it's just less effort at every call site. Secondly, it protects against the risk of accidentally leaving off the NULL, causing arbitrary words of stack memory to be dereferenced as char pointers. And thirdly, it protects against the more subtle risk of writing a bare 'NULL' as the terminating argument, instead of casting it explicitly to a pointer. That last one is necessary because C permits the macro NULL to expand to an integer constant such as 0, so NULL by itself may not have pointer type, and worse, it may not be marshalled in a variadic argument list in the same way as a pointer. (For example, on a 64-bit machine it might only occupy 32 bits. And yet, on another 64-bit platform, it might work just fine, so that you don't notice the mistake!) I was inspired to do this by happening to notice one of those bare NULL terminators, and thinking I'd better check if there were any more. Turned out there were quite a few. Now there are none. --- cmdgen.c | 2 +- config.c | 6 +++--- misc.h | 3 ++- pscp.c | 15 +++++++-------- psftp.c | 14 +++++++------- settings.c | 3 +-- ssh2transport.c | 4 +--- sshgssc.c | 2 +- sshshare.c | 2 +- unix/gtkdlg.c | 10 +++++----- unix/gtkfont.c | 13 +++++-------- unix/gtkwin.c | 11 +++++------ unix/ux_x11.c | 4 ++-- unix/uxpgnt.c | 2 +- unix/uxpty.c | 2 +- unix/uxputty.c | 4 ++-- unix/uxsftp.c | 2 +- unix/uxshare.c | 6 +++--- unix/uxstore.c | 6 +++--- utils.c | 2 +- windows/windlg.c | 2 +- windows/wingss.c | 2 +- windows/winjump.c | 5 ++--- windows/winmisc.c | 2 +- windows/winpgnt.c | 2 +- windows/winsftp.c | 8 ++++---- windows/winstore.c | 24 ++++++++++-------------- 27 files changed, 73 insertions(+), 85 deletions(-) diff --git a/cmdgen.c b/cmdgen.c index eaaf2e48..8b39f1d8 100644 --- a/cmdgen.c +++ b/cmdgen.c @@ -619,7 +619,7 @@ int main(int argc, char **argv) (intype == SSH_KEYTYPE_SSHCOM && outtype == SSHCOM)) { if (!outfile) { outfile = infile; - outfiletmp = dupcat(outfile, ".tmp", NULL); + outfiletmp = dupcat(outfile, ".tmp"); } if (!change_passphrase && !comment) { diff --git a/config.c b/config.c index a265dda5..db83adb4 100644 --- a/config.c +++ b/config.c @@ -1104,7 +1104,7 @@ static void environ_handler(union control *ctrl, dlgparam *dlg, return; } conf_set_str_str(conf, CONF_environmt, key, val); - str = dupcat(key, "\t", val, NULL); + str = dupcat(key, "\t", val); dlg_editbox_set(ed->varbox, dlg, ""); dlg_editbox_set(ed->valbox, dlg, ""); sfree(str); @@ -1235,7 +1235,7 @@ static void portfwd_handler(union control *ctrl, dlgparam *dlg, val = dupstr("D"); /* special case */ } - key = dupcat(family, type, src, NULL); + key = dupcat(family, type, src); sfree(src); if (conf_get_str_str_opt(conf, CONF_portfwd, key)) { @@ -1402,7 +1402,7 @@ static void clipboard_selector_handler(union control *ctrl, dlgparam *dlg, if (!strcmp(sval, options[i].name)) break; /* needs escaping */ if (i < lenof(options) || sval[0] == '=') { - char *escaped = dupcat("=", sval, (const char *)NULL); + char *escaped = dupcat("=", sval); dlg_editbox_set(ctrl, dlg, escaped); sfree(escaped); } else { diff --git a/misc.h b/misc.h index 6991d8e8..b9fb5721 100644 --- a/misc.h +++ b/misc.h @@ -41,7 +41,8 @@ char *host_strduptrim(const char *s); #endif /* __GNUC__ */ char *dupstr(const char *s); -char *dupcat(const char *s1, ...); +char *dupcat_fn(const char *s1, ...); +#define dupcat(...) dupcat_fn(__VA_ARGS__, (const char *)NULL) char *dupprintf(const char *fmt, ...) #ifdef __GNUC__ __attribute__ ((format (PUTTY_PRINTF_ARCHETYPE, 1, 2))) diff --git a/pscp.c b/pscp.c index bcf18dcf..4724622d 100644 --- a/pscp.c +++ b/pscp.c @@ -120,7 +120,7 @@ static void tell_user(FILE *stream, const char *fmt, ...) va_start(ap, fmt); str = dupvprintf(fmt, ap); va_end(ap); - str2 = dupcat(str, "\n", NULL); + str2 = dupcat(str, "\n"); sfree(str); abandon_stats(); tell_str(stream, str2); @@ -231,7 +231,7 @@ static NORETURN void bump(const char *fmt, ...) va_start(ap, fmt); str = dupvprintf(fmt, ap); va_end(ap); - str2 = dupcat(str, "\n", NULL); + str2 = dupcat(str, "\n"); sfree(str); abandon_stats(); tell_str(stderr, str2); @@ -762,7 +762,7 @@ int scp_send_filename(const char *name, uint64_t size, int permissions) struct fxp_attrs attrs; if (scp_sftp_targetisdir) { - fullname = dupcat(scp_sftp_remotepath, "/", name, NULL); + fullname = dupcat(scp_sftp_remotepath, "/", name); } else { fullname = dupstr(scp_sftp_remotepath); } @@ -917,7 +917,7 @@ int scp_send_dirname(const char *name, int modes) bool ret; if (scp_sftp_targetisdir) { - fullname = dupcat(scp_sftp_remotepath, "/", name, NULL); + fullname = dupcat(scp_sftp_remotepath, "/", name); } else { fullname = dupstr(scp_sftp_remotepath); } @@ -1128,8 +1128,7 @@ int scp_get_sink_action(struct scp_sink_action *act) if (head->namepos < head->namelen) { head->matched_something = true; fname = dupcat(head->dirpath, "/", - head->names[head->namepos++].filename, - NULL); + head->names[head->namepos++].filename); must_free_fname = true; } else { /* @@ -1549,7 +1548,7 @@ static void run_err(const char *fmt, ...) va_start(ap, fmt); errs++; str = dupvprintf(fmt, ap); - str2 = dupcat("pscp: ", str, "\n", NULL); + str2 = dupcat("pscp: ", str, "\n"); sfree(str); scp_send_errmsg(str2); abandon_stats(); @@ -1697,7 +1696,7 @@ static void rsource(const char *src) if (dir != NULL) { char *filename; while ((filename = read_filename(dir)) != NULL) { - char *foundfile = dupcat(src, "/", filename, NULL); + char *foundfile = dupcat(src, "/", filename); source(foundfile); sfree(foundfile); sfree(filename); diff --git a/psftp.c b/psftp.c index c0d2f9df..dd7edfd1 100644 --- a/psftp.c +++ b/psftp.c @@ -124,7 +124,7 @@ char *canonify(const char *name) slash = ""; else slash = "/"; - fullname = dupcat(pwd, slash, name, NULL); + fullname = dupcat(pwd, slash, name); } req = fxp_realpath_send(fullname); @@ -203,8 +203,8 @@ char *canonify(const char *name) * component. Concatenate the last component and return. */ returnname = dupcat(canonname, - canonname[strlen(canonname) - 1] == - '/' ? "" : "/", fullname + i + 1, NULL); + (strendswith(canonname, "/") ? "" : "/"), + fullname + i + 1); sfree(fullname); sfree(canonname); return returnname; @@ -376,7 +376,7 @@ bool sftp_get_file(char *fname, char *outfname, bool recurse, bool restart) char *nextfname, *nextoutfname; bool retd; - nextfname = dupcat(fname, "/", ournames[i]->filename, NULL); + nextfname = dupcat(fname, "/", ournames[i]->filename); nextoutfname = dir_file_cat(outfname, ournames[i]->filename); retd = sftp_get_file( nextfname, nextoutfname, recurse, restart); @@ -601,7 +601,7 @@ bool sftp_put_file(char *fname, char *outfname, bool recurse, bool restart) if (restart) { while (i < nnames) { char *nextoutfname; - nextoutfname = dupcat(outfname, "/", ournames[i], NULL); + nextoutfname = dupcat(outfname, "/", ournames[i]); req = fxp_stat_send(nextoutfname); pktin = sftp_wait_for_reply(req); result = fxp_stat_recv(pktin, req, &attrs); @@ -625,7 +625,7 @@ bool sftp_put_file(char *fname, char *outfname, bool recurse, bool restart) bool retd; nextfname = dir_file_cat(fname, ournames[i]); - nextoutfname = dupcat(outfname, "/", ournames[i], NULL); + nextoutfname = dupcat(outfname, "/", ournames[i]); retd = sftp_put_file(nextfname, nextoutfname, recurse, restart); restart = false; /* after first partial file, do full */ sfree(nextoutfname); @@ -1557,7 +1557,7 @@ static bool sftp_action_mv(void *vctx, char *srcfname) p = srcfname + strlen(srcfname); while (p > srcfname && p[-1] != '/') p--; - newname = dupcat(ctx->dstfname, "/", p, NULL); + newname = dupcat(ctx->dstfname, "/", p); newcanon = canonify(newname); sfree(newname); diff --git a/settings.c b/settings.c index d7c85e23..7bf7e4d2 100644 --- a/settings.c +++ b/settings.c @@ -490,8 +490,7 @@ static void write_clip_setting(settings_w *sesskey, const char *savekey, break; case CLIPUI_CUSTOM: { - char *sval = dupcat("custom:", conf_get_str(conf, strconfkey), - (const char *)NULL); + char *sval = dupcat("custom:", conf_get_str(conf, strconfkey)); write_setting_s(sesskey, savekey, sval); sfree(sval); } diff --git a/ssh2transport.c b/ssh2transport.c index e577c5ac..223ec5b7 100644 --- a/ssh2transport.c +++ b/ssh2transport.c @@ -1200,9 +1200,7 @@ static void ssh2_transport_process_queue(PacketProtocolLayer *ppl) if (better) { if (betteralgs) { char *old_ba = betteralgs; - betteralgs = dupcat(betteralgs, ",", - hktype->alg->ssh_id, - (const char *)NULL); + betteralgs = dupcat(betteralgs, ",", hktype->alg->ssh_id); sfree(old_ba); } else { betteralgs = dupstr(hktype->alg->ssh_id); diff --git a/sshgssc.c b/sshgssc.c index adbb4377..d9f62c39 100644 --- a/sshgssc.c +++ b/sshgssc.c @@ -25,7 +25,7 @@ static Ssh_gss_stat ssh_gssapi_import_name(struct ssh_gss_library *lib, gss_buffer_desc host_buf; char *pStr; - pStr = dupcat("host@", host, NULL); + pStr = dupcat("host@", host); host_buf.value = pStr; host_buf.length = strlen(pStr); diff --git a/sshshare.c b/sshshare.c index 4d124187..24f4c125 100644 --- a/sshshare.c +++ b/sshshare.c @@ -1858,7 +1858,7 @@ static void share_listen_closing(Plug *plug, const char *error_msg, static void share_send_verstring(ssh_sharing_connstate *cs) { char *fullstring = dupcat("SSHCONNECTION@putty.projects.tartarus.org-2.0-", - cs->parent->server_verstring, "\015\012", NULL); + cs->parent->server_verstring, "\015\012"); sk_write(cs->sock, fullstring, strlen(fullstring)); sfree(fullstring); diff --git a/unix/gtkdlg.c b/unix/gtkdlg.c index cd3f8092..c44f9306 100644 --- a/unix/gtkdlg.c +++ b/unix/gtkdlg.c @@ -3654,7 +3654,7 @@ void old_keyfile_warning(void) void nonfatal_message_box(void *window, const char *msg) { - char *title = dupcat(appname, " Error", NULL); + char *title = dupcat(appname, " Error"); create_message_box( window, title, msg, string_width("REASONABLY LONG LINE OF TEXT FOR BASIC SANITY"), @@ -3694,7 +3694,7 @@ static void licence_clicked(GtkButton *button, gpointer data) { char *title; - title = dupcat(appname, " Licence", NULL); + title = dupcat(appname, " Licence"); assert(aboutbox != NULL); create_message_box(aboutbox, title, LICENCE_TEXT("\n\n"), string_width("LONGISH LINE OF TEXT SO THE LICENCE" @@ -3716,7 +3716,7 @@ void about_box(void *window) aboutbox = our_dialog_new(); gtk_container_set_border_width(GTK_CONTAINER(aboutbox), 10); - title = dupcat("About ", appname, NULL); + title = dupcat("About ", appname); gtk_window_set_title(GTK_WINDOW(aboutbox), title); sfree(title); @@ -3932,7 +3932,7 @@ void showeventlog(eventlog_stuff *es, void *parentwin) c->listbox.percentages[2] = 65; es->window = window = our_dialog_new(); - title = dupcat(appname, " Event Log", (const char *)NULL); + title = dupcat(appname, " Event Log"); gtk_window_set_title(GTK_WINDOW(window), title); sfree(title); w0 = layout_ctrls(&es->dp, NULL, &es->scs, s0, GTK_WINDOW(window)); @@ -4025,7 +4025,7 @@ void logevent_dlg(eventlog_stuff *es, const char *string) strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S\t", &tm); sfree(*location); - *location = dupcat(timebuf, string, NULL); + *location = dupcat(timebuf, string); if (es->window) { dlg_listbox_add(es->listctrl, &es->dp, *location); } diff --git a/unix/gtkfont.c b/unix/gtkfont.c index db3dc589..4e62fb34 100644 --- a/unix/gtkfont.c +++ b/unix/gtkfont.c @@ -461,7 +461,7 @@ static unifont *x11font_create(GtkWidget *widget, const char *name, reg = XGetAtomName(disp, (Atom)registry_ret); enc = XGetAtomName(disp, (Atom)encoding_ret); if (reg && enc) { - char *encoding = dupcat(reg, "-", enc, NULL); + char *encoding = dupcat(reg, "-", enc); pubcs = realcs = charset_from_xenc(encoding); /* @@ -1280,8 +1280,7 @@ static char *x11font_size_increment(unifont *font, int increment) if (xlfd_best) { char *bare_returned_name = xlfd_recompose(xlfd_best); returned_name = dupcat( - xfont->u.vt->prefix, ":", bare_returned_name, - (const char *)NULL); + xfont->u.vt->prefix, ":", bare_returned_name); sfree(bare_returned_name); } @@ -2042,8 +2041,7 @@ static char *pangofont_size_increment(unifont *font, int increment) } else { pango_font_description_set_size(desc, size); newname = pango_font_description_to_string(desc); - retname = dupcat(pfont->u.vt->prefix, ":", - newname, (const char *)NULL); + retname = dupcat(pfont->u.vt->prefix, ":", newname); g_free(newname); } @@ -3780,15 +3778,14 @@ char *unifontsel_get_name(unifontsel *fontsel) name = fs->selected->fontclass->scale_fontname (GTK_WIDGET(fs->u.window), fs->selected->realname, fs->selsize); if (name) { - char *ret = dupcat(fs->selected->fontclass->prefix, ":", - name, NULL); + char *ret = dupcat(fs->selected->fontclass->prefix, ":", name); sfree(name); return ret; } } return dupcat(fs->selected->fontclass->prefix, ":", - fs->selected->realname, NULL); + fs->selected->realname); } #endif /* GTK_CHECK_VERSION(2,0,0) */ diff --git a/unix/gtkwin.c b/unix/gtkwin.c index 0da96184..31787237 100644 --- a/unix/gtkwin.c +++ b/unix/gtkwin.c @@ -235,7 +235,7 @@ static void post_fatal_message_box(void *vctx, int result) static void common_connfatal_message_box( GtkFrontend *inst, const char *msg, post_dialog_fn_t postfn) { - char *title = dupcat(appname, " Fatal Error", NULL); + char *title = dupcat(appname, " Fatal Error"); GtkWidget *dialog = create_message_box( inst->window, title, msg, string_width("REASONABLY LONG LINE OF TEXT FOR BASIC SANITY"), @@ -661,7 +661,7 @@ gint delete_window(GtkWidget *widget, GdkEvent *event, GtkFrontend *inst) * case we'll just re-emphasise that one. */ if (!find_and_raise_dialog(inst, DIALOG_SLOT_WARN_ON_CLOSE)) { - char *title = dupcat(appname, " Exit Confirmation", NULL); + char *title = dupcat(appname, " Exit Confirmation"); GtkWidget *dialog = create_message_box( inst->window, title, "Are you sure you want to close this session?", @@ -1080,8 +1080,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data) char *old = state_string; state_string = dupcat(state_string, state_string[0] ? "|" : "", - mod_bits[i].name, - (char *)NULL); + mod_bits[i].name); sfree(old); val &= ~mod_bits[i].mod_bit; @@ -4596,7 +4595,7 @@ void change_settings_menuitem(GtkMenuItem *item, gpointer data) if (find_and_raise_dialog(inst, DIALOG_SLOT_RECONFIGURE)) return; - title = dupcat(appname, " Reconfiguration", NULL); + title = dupcat(appname, " Reconfiguration"); ctx = snew(struct after_change_settings_dialog_ctx); ctx->inst = inst; @@ -5489,7 +5488,7 @@ void new_session_window(Conf *conf, const char *geometry_string) paste_clipboard_menuitem); MKMENUITEM("Copy All", copy_all_menuitem); MKSEP(); - s = dupcat("About ", appname, NULL); + s = dupcat("About ", appname); MKMENUITEM(s, about_menuitem); sfree(s); #undef MKMENUITEM diff --git a/unix/ux_x11.c b/unix/ux_x11.c index bef036b4..7a0c2218 100644 --- a/unix/ux_x11.c +++ b/unix/ux_x11.c @@ -27,7 +27,7 @@ void platform_get_x11_auth(struct X11Display *disp, Conf *conf) if (!xauthfile) { xauthfile = getenv("HOME"); if (xauthfile) { - xauthfile = dupcat(xauthfile, "/.Xauthority", NULL); + xauthfile = dupcat(xauthfile, "/.Xauthority"); needs_free = true; } } @@ -127,7 +127,7 @@ int platform_make_x11_server(Plug *plug, const char *progname, int mindisp, if (!tmpdir || !*tmpdir) tmpdir = "/tmp"; - authfilename = dupcat(tmpdir, "/", progname, "-Xauthority-XXXXXX", NULL); + authfilename = dupcat(tmpdir, "/", progname, "-Xauthority-XXXXXX"); { int oldumask = umask(077); diff --git a/unix/uxpgnt.c b/unix/uxpgnt.c index 9c5f4942..61a94334 100644 --- a/unix/uxpgnt.c +++ b/unix/uxpgnt.c @@ -329,7 +329,7 @@ static char *askpass_tty(const char *prompt) p->to_server = false; p->from_server = false; p->name = dupstr("Pageant passphrase prompt"); - add_prompt(p, dupcat(prompt, ": ", (const char *)NULL), false); + add_prompt(p, dupcat(prompt, ": "), false); ret = console_get_userpass_input(p); assert(ret >= 0); diff --git a/unix/uxpty.c b/unix/uxpty.c index e57770f5..2533d958 100644 --- a/unix/uxpty.c +++ b/unix/uxpty.c @@ -1134,7 +1134,7 @@ Backend *pty_backend_create( for (val = conf_get_str_strs(conf, CONF_environmt, NULL, &key); val != NULL; val = conf_get_str_strs(conf, CONF_environmt, key, &key)) { - char *varval = dupcat(key, "=", val, NULL); + char *varval = dupcat(key, "=", val); putenv(varval); /* * We must not free varval, since putenv links it diff --git a/unix/uxputty.c b/unix/uxputty.c index 8142bdd0..7449c3ab 100644 --- a/unix/uxputty.c +++ b/unix/uxputty.c @@ -47,7 +47,7 @@ const struct BackendVtable *select_backend(Conf *conf) void initial_config_box(Conf *conf, post_dialog_fn_t after, void *afterctx) { - char *title = dupcat(appname, " Configuration", NULL); + char *title = dupcat(appname, " Configuration"); create_config_box(title, conf, false, 0, after, afterctx); sfree(title); } @@ -57,7 +57,7 @@ const bool dup_check_launchable = true; char *make_default_wintitle(char *hostname) { - return dupcat(hostname, " - ", appname, NULL); + return dupcat(hostname, " - ", appname); } /* diff --git a/unix/uxsftp.c b/unix/uxsftp.c index de838f88..3195f902 100644 --- a/unix/uxsftp.c +++ b/unix/uxsftp.c @@ -460,7 +460,7 @@ char *dir_file_cat(const char *dir, const char *file) ptrlen dir_pl = ptrlen_from_asciz(dir); return dupcat( dir, ptrlen_endswith(dir_pl, PTRLEN_LITERAL("/"), NULL) ? "" : "/", - file, NULL); + file); } /* diff --git a/unix/uxshare.c b/unix/uxshare.c index 0c5265bf..f1ef2019 100644 --- a/unix/uxshare.c +++ b/unix/uxshare.c @@ -273,7 +273,7 @@ int platform_ssh_share(const char *pi_name, Conf *conf, /* * Acquire a lock on a file in that directory. */ - lockname = dupcat(dirname, "/lock", (char *)NULL); + lockname = dupcat(dirname, "/lock"); lockfd = open(lockname, O_CREAT | O_RDWR | O_TRUNC, 0600); if (lockfd < 0) { *logtext = dupprintf("%s: open: %s", lockname, strerror(errno)); @@ -348,11 +348,11 @@ void platform_ssh_share_cleanup(const char *name) return; } - filename = dupcat(dirname, "/socket", (char *)NULL); + filename = dupcat(dirname, "/socket"); remove(filename); sfree(filename); - filename = dupcat(dirname, "/lock", (char *)NULL); + filename = dupcat(dirname, "/lock"); remove(filename); sfree(filename); diff --git a/unix/uxstore.c b/unix/uxstore.c index 250db9a8..b3a5b8a7 100644 --- a/unix/uxstore.c +++ b/unix/uxstore.c @@ -449,7 +449,7 @@ FontSpec *read_setting_fontspec(settings_r *handle, const char *name) * provided name string (e.g. "Font") to a suffixed one * ("FontName"). */ - char *suffname = dupcat(name, "Name", NULL); + char *suffname = dupcat(name, "Name"); char *tmp; if ((tmp = read_setting_s(handle, suffname)) != NULL) { @@ -463,7 +463,7 @@ FontSpec *read_setting_fontspec(settings_r *handle, const char *name) /* Fall back to old-style name. */ tmp = read_setting_s(handle, name); if (tmp && *tmp) { - char *tmp2 = dupcat("server:", tmp, NULL); + char *tmp2 = dupcat("server:", tmp); FontSpec *fs = fontspec_new(tmp2); sfree(tmp2); sfree(tmp); @@ -491,7 +491,7 @@ void write_setting_fontspec(settings_w *handle, const char *name, FontSpec *fs) * writing our settings back out we simply always generate the * new-style name. */ - char *suffname = dupcat(name, "Name", NULL); + char *suffname = dupcat(name, "Name"); write_setting_s(handle, suffname, fs->name); sfree(suffname); } diff --git a/utils.c b/utils.c index 18193960..6cd1cf4c 100644 --- a/utils.c +++ b/utils.c @@ -249,7 +249,7 @@ char *dupstr(const char *s) } /* Allocate the concatenation of N strings. Terminate arg list with NULL. */ -char *dupcat(const char *s1, ...) +char *dupcat_fn(const char *s1, ...) { int len; char *p, *q, *sn; diff --git a/windows/windlg.c b/windows/windlg.c index faa56935..26bea503 100644 --- a/windows/windlg.c +++ b/windows/windlg.c @@ -776,7 +776,7 @@ static void win_gui_eventlog(LogPolicy *lp, const char *string) if (*location) sfree(*location); - *location = dupcat(timebuf, string, (const char *)NULL); + *location = dupcat(timebuf, string); if (logbox) { int count; SendDlgItemMessage(logbox, IDN_LIST, LB_ADDSTRING, diff --git a/windows/wingss.c b/windows/wingss.c index 6744475b..10e6d2db 100644 --- a/windows/wingss.c +++ b/windows/wingss.c @@ -308,7 +308,7 @@ static Ssh_gss_stat ssh_sspi_import_name(struct ssh_gss_library *lib, if (host == NULL) return SSH_GSS_FAILURE; /* copy it into form host/FQDN */ - pStr = dupcat("host/", host, NULL); + pStr = dupcat("host/", host); *srv_name = (Ssh_gss_name) pStr; diff --git a/windows/winjump.c b/windows/winjump.c index 595bbe08..358504fd 100644 --- a/windows/winjump.c +++ b/windows/winjump.c @@ -432,7 +432,7 @@ static IShellLink *make_shell_link(const char *appname, * behaviour change in which an argument string starting with * '@' causes the SetArguments method to silently do the wrong * thing. */ - param_string = dupcat(" @", sessionname, NULL); + param_string = dupcat(" @", sessionname); } else { param_string = dupstr(""); } @@ -440,8 +440,7 @@ static IShellLink *make_shell_link(const char *appname, sfree(param_string); if (sessionname) { - desc_string = dupcat("Connect to PuTTY session '", - sessionname, "'", NULL); + desc_string = dupcat("Connect to PuTTY session '", sessionname, "'"); } else { assert(appname); desc_string = dupprintf("Run %.*s", diff --git a/windows/winmisc.c b/windows/winmisc.c index 9ccb65fd..8cbdda08 100644 --- a/windows/winmisc.c +++ b/windows/winmisc.c @@ -233,7 +233,7 @@ HMODULE load_system32_dll(const char *libname) sgrowarray(sysdir, sysdirsize, len); } - fullpath = dupcat(sysdir, "\\", libname, NULL); + fullpath = dupcat(sysdir, "\\", libname); ret = LoadLibrary(fullpath); sfree(fullpath); return ret; diff --git a/windows/winpgnt.c b/windows/winpgnt.c index 718feb9f..0dbf32e8 100644 --- a/windows/winpgnt.c +++ b/windows/winpgnt.c @@ -451,7 +451,7 @@ static void prompt_add_keyfile(void) char *dir = filelist; char *filewalker = filelist + strlen(dir) + 1; while (*filewalker != '\0') { - char *filename = dupcat(dir, "\\", filewalker, NULL); + char *filename = dupcat(dir, "\\", filewalker); Filename *fn = filename_from_str(filename); win_add_keyfile(fn); filename_free(fn); diff --git a/windows/winsftp.c b/windows/winsftp.c index ab323404..b120890c 100644 --- a/windows/winsftp.c +++ b/windows/winsftp.c @@ -274,7 +274,7 @@ DirHandle *open_directory(const char *name, const char **errmsg) DirHandle *ret; /* Enumerate files in dir `foo'. */ - findfile = dupcat(name, "/*", NULL); + findfile = dupcat(name, "/*"); h = FindFirstFile(findfile, &fdat); if (h == INVALID_HANDLE_VALUE) { *errmsg = win_strerror(GetLastError()); @@ -395,7 +395,7 @@ WildcardMatcher *begin_wildcard_matching(const char *name) (fdat.cFileName[1] == '.' && fdat.cFileName[2] == '\0'))) ret->name = NULL; else - ret->name = dupcat(ret->srcpath, fdat.cFileName, NULL); + ret->name = dupcat(ret->srcpath, fdat.cFileName); return ret; } @@ -413,7 +413,7 @@ char *wildcard_get_filename(WildcardMatcher *dir) (fdat.cFileName[1] == '.' && fdat.cFileName[2] == '\0'))) dir->name = NULL; else - dir->name = dupcat(dir->srcpath, fdat.cFileName, NULL); + dir->name = dupcat(dir->srcpath, fdat.cFileName); } if (dir->name) { @@ -455,7 +455,7 @@ char *dir_file_cat(const char *dir, const char *file) return dupcat( dir, (ptrlen_endswith(dir_pl, PTRLEN_LITERAL("\\"), NULL) || ptrlen_endswith(dir_pl, PTRLEN_LITERAL("/"), NULL)) ? "" : "\\", - file, NULL); + file); } /* ---------------------------------------------------------------------- diff --git a/windows/winstore.c b/windows/winstore.c index 1fba6ddb..09e5c028 100644 --- a/windows/winstore.c +++ b/windows/winstore.c @@ -175,7 +175,7 @@ FontSpec *read_setting_fontspec(settings_r *handle, const char *name) if (!fontname) return NULL; - settingname = dupcat(name, "IsBold", NULL); + settingname = dupcat(name, "IsBold"); isbold = read_setting_i(handle, settingname, -1); sfree(settingname); if (isbold == -1) { @@ -183,7 +183,7 @@ FontSpec *read_setting_fontspec(settings_r *handle, const char *name) return NULL; } - settingname = dupcat(name, "CharSet", NULL); + settingname = dupcat(name, "CharSet"); charset = read_setting_i(handle, settingname, -1); sfree(settingname); if (charset == -1) { @@ -191,7 +191,7 @@ FontSpec *read_setting_fontspec(settings_r *handle, const char *name) return NULL; } - settingname = dupcat(name, "Height", NULL); + settingname = dupcat(name, "Height"); height = read_setting_i(handle, settingname, INT_MIN); sfree(settingname); if (height == INT_MIN) { @@ -210,13 +210,13 @@ void write_setting_fontspec(settings_w *handle, char *settingname; write_setting_s(handle, name, font->name); - settingname = dupcat(name, "IsBold", NULL); + settingname = dupcat(name, "IsBold"); write_setting_i(handle, settingname, font->isbold); sfree(settingname); - settingname = dupcat(name, "CharSet", NULL); + settingname = dupcat(name, "CharSet"); write_setting_i(handle, settingname, font->charset); sfree(settingname); - settingname = dupcat(name, "Height", NULL); + settingname = dupcat(name, "Height"); write_setting_i(handle, settingname, font->height); sfree(settingname); } @@ -551,15 +551,13 @@ static HANDLE access_random_seed(int action) char profile[MAX_PATH + 1]; if (SUCCEEDED(p_SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, profile)) && - try_random_seed_and_free(dupcat(profile, "\\PUTTY.RND", - (const char *)NULL), + try_random_seed_and_free(dupcat(profile, "\\PUTTY.RND"), action, &rethandle)) return rethandle; if (SUCCEEDED(p_SHGetFolderPathA(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, profile)) && - try_random_seed_and_free(dupcat(profile, "\\PUTTY.RND", - (const char *)NULL), + try_random_seed_and_free(dupcat(profile, "\\PUTTY.RND"), action, &rethandle)) return rethandle; } @@ -582,8 +580,7 @@ static HANDLE access_random_seed(int action) if (drvlen < lenof(drv) && pathlen < lenof(path) && pathlen > 0 && try_random_seed_and_free( - dupcat(drv, path, "\\PUTTY.RND", (const char *)NULL), - action, &rethandle)) + dupcat(drv, path, "\\PUTTY.RND"), action, &rethandle)) return rethandle; } @@ -595,8 +592,7 @@ static HANDLE access_random_seed(int action) DWORD len = GetWindowsDirectory(windir, sizeof(windir)); if (len < lenof(windir) && try_random_seed_and_free( - dupcat(windir, "\\PUTTY.RND", (const char *)NULL), - action, &rethandle)) + dupcat(windir, "\\PUTTY.RND"), action, &rethandle)) return rethandle; }