Use safe_malloc/FREE and the safe_strcat functions. -- Kevin J. McCarthy GPG Fingerprint: 8975 A9B3 3AA3 7910 385C 5308 ADEF 7684 8031 6BDA
# HG changeset patch # User Kevin McCarthy <[email protected]> # Date 1464744517 25200 # Tue May 31 18:28:37 2016 -0700 # Node ID 7a2f763782c918ebdec746dd8f02982920245a2c # Parent 717a06441fafe2c72ef607fc282226b1a1cac654 Fix sidebar check_sec.sh warnings.
Use safe_malloc/FREE and the safe_strcat functions.
diff --git a/sidebar.c b/sidebar.c
--- a/sidebar.c
+++ b/sidebar.c
@@ -473,18 +473,16 @@
if (!b)
return 0;
int count = 0;
for (; b; b = b->next)
count++;
BUFFY **arr = safe_malloc (count * sizeof (*arr));
- if (!arr)
- return 0;
int i = 0;
for (b = Incoming; b; b = b->next, i++) {
arr[i] = b;
}
update_buffy_visibility (arr, count);
sort_buffy_array (arr, count);
@@ -523,17 +521,17 @@
if (bot_index > (count - 1)) {
bot_index = count - 1;
}
BotBuffy = arr[bot_index];
Outgoing = arr[count - 1];
PreviousSort = SidebarSortMethod;
- free (arr);
+ FREE (&arr);
return 1;
}
/**
* draw_divider - Draw a line between the sidebar and the rest of mutt
* @num_rows: Height of the Sidebar
* @num_cols: Width of the Sidebar
*
@@ -694,28 +692,29 @@
sidebar_folder_depth++;
lastsep = i + 1;
}
}
if (sidebar_folder_depth > 0) {
if (option (OPTSIDEBARSHORTPATH)) {
tmp_folder_name += lastsep; /*
basename */
}
- sidebar_folder_name = malloc (strlen
(tmp_folder_name) + sidebar_folder_depth*strlen (NONULL(SidebarIndentString)) +
1);
+ int sfn_len = strlen (tmp_folder_name) +
sidebar_folder_depth*strlen (NONULL(SidebarIndentString)) + 1;
+ sidebar_folder_name = safe_malloc (sfn_len);
sidebar_folder_name[0]=0;
for (i=0; i < sidebar_folder_depth; i++)
- strncat (sidebar_folder_name,
NONULL(SidebarIndentString), strlen (NONULL(SidebarIndentString)));
- strncat (sidebar_folder_name, tmp_folder_name,
strlen (tmp_folder_name));
+ safe_strcat (sidebar_folder_name, sfn_len,
NONULL(SidebarIndentString));
+ safe_strcat (sidebar_folder_name, sfn_len,
tmp_folder_name);
}
}
char str[SHORT_STRING];
make_sidebar_entry (str, sizeof (str), w, sidebar_folder_name,
b);
printw ("%s", str);
if (sidebar_folder_depth > 0)
- free (sidebar_folder_name);
+ FREE (&sidebar_folder_name);
row++;
}
fill_empty_space (row, num_rows - row, w);
}
/**
signature.asc
Description: PGP signature
