Prefer dynamically allocated buffers to fixed-size ones, use the same
This commit is contained in:
parent
a875f48b7d
commit
498b61cc58
|
@ -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");
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue