talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 498b61cc586e6e258fb9299d14b49ec831ccb0f8
parent a875f48b7d47a10c29acc8775cd127f61b42b265
Author: wwp <wwp@free.fr>
Date:   Fri, 13 Jan 2017 09:19:41 +0100

Prefer dynamically allocated buffers to fixed-size ones, use the same

Diffstat:
Msrc/compose.c | 14+++++++-------
Msrc/crash.c | 3++-
Msrc/plugins/pgpcore/pgp_viewer.c | 1+
Msrc/plugins/vcalendar/libical/libical/icalproperty.c | 13+++++++------
Msrc/textview.c | 1+
5 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/src/compose.c b/src/compose.c @@ -9478,7 +9478,7 @@ static gboolean compose_get_ext_editor_cmd_valid() static gint compose_exec_ext_editor_real(const gchar *file, GdkNativeWindow socket_wid) { - gchar buf[1024]; + gchar *buf; gchar *p, *s; gchar **cmdline; pid_t pid; @@ -9503,22 +9503,22 @@ static gint compose_exec_ext_editor_real(const gchar *file, GdkNativeWindow sock s = strstr(p, "%w"); s[1] = 'u'; if (strstr(p, "%s") < s) - g_snprintf(buf, sizeof(buf), p, file, socket_wid); + buf = g_strdup_printf(p, file, socket_wid); else - g_snprintf(buf, sizeof(buf), p, socket_wid, file); + buf = g_strdup_printf(p, socket_wid, file); g_free(p); } else { - g_snprintf(buf, sizeof(buf), - prefs_common_get_ext_editor_cmd(), file); + buf = g_strdup_printf(prefs_common_get_ext_editor_cmd(), file); } } else { if (prefs_common_get_ext_editor_cmd()) g_warning("External editor command-line is invalid: '%s'", prefs_common_get_ext_editor_cmd()); - g_snprintf(buf, sizeof(buf), DEFAULT_EDITOR_CMD, file); + buf = g_strdup_printf(DEFAULT_EDITOR_CMD, file); } - cmdline = strsplit_with_quote(buf, " ", 1024); + cmdline = strsplit_with_quote(buf, " ", 0); + g_free(buf); execvp(cmdline[0], cmdline); perror("execvp"); diff --git a/src/crash.c b/src/crash.c @@ -369,7 +369,7 @@ static void crash_debug(unsigned long crash_pid, perror("dup"); close(choutput[0]); if (-1 == execvp("gdb", argp)) - g_print("error execvp\n"); + perror("execvp"); } else { char buf[100]; int r; @@ -547,6 +547,7 @@ static void crash_handler(int sig) if (setuid(getuid()) != 0 ) perror("setuid"); execvp(argv0, args); + perror("execvp"); } else { waitpid(pid, NULL, 0); crash_cleanup_exit(); diff --git a/src/plugins/pgpcore/pgp_viewer.c b/src/plugins/pgpcore/pgp_viewer.c @@ -208,6 +208,7 @@ static void pgpview_show_mime_part(TextView *textview, MimeInfo *partinfo) gchar **argv; argv = strsplit_with_quote(cmd, " ", 0); res = execvp(argv[0], argv); + perror("execvp"); exit(255); } else { int status = 0; diff --git a/src/plugins/vcalendar/libical/libical/icalproperty.c b/src/plugins/vcalendar/libical/libical/icalproperty.c @@ -44,8 +44,8 @@ #include <errno.h> #include <stdio.h> /* for printf */ #include <stdarg.h> /* for va_list, va_start, etc. */ - -#define TMP_BUF_SIZE 1024 + +#define BUF_SIZE 1024 /* Private routines for icalproperty */ void icalvalue_set_parent(icalvalue* value, @@ -175,7 +175,7 @@ icalproperty_new_clone(icalproperty* prop) icalproperty* icalproperty_new_from_string(char* str) { - size_t buf_size = 1024; + size_t buf_size = BUF_SIZE; char* buf; char* buf_ptr; icalproperty *prop; @@ -279,7 +279,7 @@ icalproperty_as_ical_string (icalproperty* prop) the caller forgetting to free it */ const char* property_name = 0; - size_t buf_size = 1024; + size_t buf_size = BUF_SIZE; char* buf; char* buf_ptr; icalvalue* value; @@ -381,9 +381,10 @@ icalproperty_as_ical_string (icalproperty* prop) } if (kind_string == 0 ) { - char temp[TMP_BUF_SIZE]; - snprintf(temp, TMP_BUF_SIZE,"Got a parameter of unknown kind in %s property",property_name); + char *temp; + temp = g_strdup_printf(temp, "Got a parameter of unknown kind in %s property", property_name); icalerror_warn(temp); + g_free(temp); continue; } diff --git a/src/textview.c b/src/textview.c @@ -1141,6 +1141,7 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo) close(pfd[0]); rc = dup(pfd[1]); rc = execvp(argv[0], argv); + perror("execvp"); close(pfd[1]); g_print(_("The command to view attachment " "as text failed:\n"