Replace sprintf with snprintf
This commit is contained in:
@@ -1312,19 +1312,19 @@ void set_panel_items(const char *items)
|
||||
} else if (v == ':') {
|
||||
separator_index++;
|
||||
buffer[0] = 0;
|
||||
sprintf(buffer, "%s %d", _("Separator"), separator_index + 1);
|
||||
snprintf(buffer, sizeof(buffer), "%s %d", _("Separator"), separator_index + 1);
|
||||
name = buffer;
|
||||
value = ":";
|
||||
} else if (v == 'E') {
|
||||
execp_index++;
|
||||
buffer[0] = 0;
|
||||
sprintf(buffer, "%s %d", _("Executor"), execp_index + 1);
|
||||
snprintf(buffer, sizeof(buffer), "%s %d", _("Executor"), execp_index + 1);
|
||||
name = buffer;
|
||||
value = "E";
|
||||
} else if (v == 'P') {
|
||||
button_index++;
|
||||
buffer[0] = 0;
|
||||
sprintf(buffer, "%s %d", _("Button"), button_index + 1);
|
||||
snprintf(buffer, sizeof(buffer), "%s %d", _("Button"), button_index + 1);
|
||||
name = buffer;
|
||||
value = "P";
|
||||
} else {
|
||||
@@ -4097,7 +4097,7 @@ void create_separator(GtkWidget *notebook, int i)
|
||||
Separator *separator = &g_array_index(separators, Separator, i);
|
||||
|
||||
separator->name[0] = 0;
|
||||
sprintf(separator->name, "%s %d", _("Separator"), i + 1);
|
||||
snprintf(separator->name, sizeof(separator->name), "%s %d", _("Separator"), i + 1);
|
||||
separator->page_label = gtk_label_new(separator->name);
|
||||
gtk_widget_show(separator->page_label);
|
||||
separator->page_separator = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING);
|
||||
@@ -4223,7 +4223,7 @@ void create_execp(GtkWidget *notebook, int i)
|
||||
Executor *executor = &g_array_index(executors, Executor, i);
|
||||
|
||||
executor->name[0] = 0;
|
||||
sprintf(executor->name, "%s %d", _("Executor"), i + 1);
|
||||
snprintf(executor->name, sizeof(executor->name), "%s %d", _("Executor"), i + 1);
|
||||
executor->page_label = gtk_label_new(executor->name);
|
||||
gtk_widget_show(executor->page_label);
|
||||
executor->page_execp = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING);
|
||||
@@ -4644,7 +4644,7 @@ void create_button(GtkWidget *notebook, int i)
|
||||
Button *button = &g_array_index(buttons, Button, i);
|
||||
|
||||
button->name[0] = 0;
|
||||
sprintf(button->name, "%s %d", _("Button"), i + 1);
|
||||
snprintf(button->name, sizeof(button->name), "%s %d", _("Button"), i + 1);
|
||||
button->page_label = gtk_label_new(button->name);
|
||||
gtk_widget_show(button->page_label);
|
||||
button->page_button = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING);
|
||||
@@ -5033,7 +5033,7 @@ void separator_update_indices()
|
||||
{
|
||||
for (int i = 0; i < separators->len; i++) {
|
||||
Separator *separator = &g_array_index(separators, Separator, i);
|
||||
sprintf(separator->name, "%s %d", _("Separator"), i + 1);
|
||||
snprintf(separator->name, sizeof(separator->name), "%s %d", _("Separator"), i + 1);
|
||||
gtk_label_set_text(GTK_LABEL(separator->page_label), separator->name);
|
||||
}
|
||||
|
||||
@@ -5051,7 +5051,7 @@ void separator_update_indices()
|
||||
separator_index++;
|
||||
char buffer[256];
|
||||
buffer[0] = 0;
|
||||
sprintf(buffer, "%s %d", _("Separator"), separator_index + 1);
|
||||
snprintf(buffer, sizeof(buffer), "%s %d", _("Separator"), separator_index + 1);
|
||||
|
||||
gtk_list_store_set(panel_items, &iter, itemsColName, buffer, -1);
|
||||
}
|
||||
@@ -5065,7 +5065,7 @@ void execp_update_indices()
|
||||
{
|
||||
for (int i = 0; i < executors->len; i++) {
|
||||
Executor *executor = &g_array_index(executors, Executor, i);
|
||||
sprintf(executor->name, "%s %d", _("Executor"), i + 1);
|
||||
snprintf(executor->name, sizeof(executor->name), "%s %d", _("Executor"), i + 1);
|
||||
gtk_label_set_text(GTK_LABEL(executor->page_label), executor->name);
|
||||
}
|
||||
|
||||
@@ -5083,7 +5083,7 @@ void execp_update_indices()
|
||||
execp_index++;
|
||||
char buffer[256];
|
||||
buffer[0] = 0;
|
||||
sprintf(buffer, "%s %d", _("Executor"), execp_index + 1);
|
||||
snprintf(buffer, sizeof(buffer), "%s %d", _("Executor"), execp_index + 1);
|
||||
|
||||
gtk_list_store_set(panel_items, &iter, itemsColName, buffer, -1);
|
||||
}
|
||||
@@ -5097,7 +5097,7 @@ void button_update_indices()
|
||||
{
|
||||
for (int i = 0; i < buttons->len; i++) {
|
||||
Button *button = &g_array_index(buttons, Button, i);
|
||||
sprintf(button->name, "%s %d", _("Button"), i + 1);
|
||||
snprintf(button->name, sizeof(button->name), "%s %d", _("Button"), i + 1);
|
||||
gtk_label_set_text(GTK_LABEL(button->page_label), button->name);
|
||||
}
|
||||
|
||||
@@ -5115,7 +5115,7 @@ void button_update_indices()
|
||||
button_index++;
|
||||
char buffer[256];
|
||||
buffer[0] = 0;
|
||||
sprintf(buffer, "%s %d", _("Button"), button_index + 1);
|
||||
snprintf(buffer, sizeof(buffer), "%s %d", _("Button"), button_index + 1);
|
||||
|
||||
gtk_list_store_set(panel_items, &iter, itemsColName, buffer, -1);
|
||||
}
|
||||
|
||||
@@ -478,7 +478,7 @@ void config_write_task_font_color(FILE *fp, char *name, GtkWidget *task_color)
|
||||
GdkColor color;
|
||||
gtk_color_button_get_color(GTK_COLOR_BUTTON(task_color), &color);
|
||||
char full_name[128];
|
||||
sprintf(full_name, "task%s_font_color", name);
|
||||
snprintf(full_name, sizeof(full_name), "task%s_font_color", name);
|
||||
config_write_color(fp, full_name, color, gtk_color_button_get_alpha(GTK_COLOR_BUTTON(task_color)) * 100 / 0xffff);
|
||||
}
|
||||
|
||||
@@ -489,7 +489,7 @@ void config_write_task_icon_osb(FILE *fp,
|
||||
GtkWidget *widget_brightness)
|
||||
{
|
||||
char full_name[128];
|
||||
sprintf(full_name, "task%s_icon_asb", name);
|
||||
snprintf(full_name, sizeof(full_name), "task%s_icon_asb", name);
|
||||
fprintf(fp,
|
||||
"%s = %d %d %d\n",
|
||||
full_name,
|
||||
@@ -501,7 +501,7 @@ void config_write_task_icon_osb(FILE *fp,
|
||||
void config_write_task_background(FILE *fp, char *name, GtkWidget *task_background)
|
||||
{
|
||||
char full_name[128];
|
||||
sprintf(full_name, "task%s_background_id", name);
|
||||
snprintf(full_name, sizeof(full_name), "task%s_background_id", name);
|
||||
fprintf(fp, "%s = %d\n", full_name, gtk_combo_box_get_active(GTK_COMBO_BOX(task_background)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user