mu: fix strncpy usage
Ensure the resulting strings are \0-terminated.
This commit is contained in:
@ -344,7 +344,8 @@ field_string_list (MuMsg *msg, MuMsgFieldId mfid)
|
||||
|
||||
str = mu_str_from_list (lst, ',');
|
||||
if (str) {
|
||||
strncpy (buf, str, sizeof(buf));
|
||||
strncpy (buf, str, sizeof(buf)-1);
|
||||
buf[sizeof(buf)-1]='\0';
|
||||
g_free (str);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@ -1406,7 +1406,8 @@ get_path_from_docid (MuStore *store, unsigned docid, GError **err)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strncpy (path, msgpath, sizeof(path));
|
||||
strncpy (path, msgpath, sizeof(path) - 1);
|
||||
path[sizeof(path)-1] = '\0';
|
||||
|
||||
mu_msg_unref (msg);
|
||||
return path;
|
||||
|
||||
Reference in New Issue
Block a user