less horrible strncpy's
[apps/madmutt.git] / browser.c
index 3fd3563..53bab1a 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -350,7 +350,7 @@ static const char *newsgroup_format_str (char *dest, size_t destlen, char op,
     break;
 
   case 'f':
-    strncpy (fn, folder->ff->name, sizeof (fn) - 1);
+    m_strcpy(fn, sizeof(fn), folder->ff->name);
     snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
     snprintf (dest, destlen, tmp, fn);
     break;
@@ -779,10 +779,8 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
       for (i = m_strlen(f) - 1; i > 0 && f[i] != '/'; i--);
       if (i > 0) {
         if (f[0] == '/') {
-          if (i > sizeof (LastDir) - 1)
-            i = sizeof (LastDir) - 1;
-          strncpy (LastDir, f, i);
-          LastDir[i] = 0;
+          i = MIN(sizeof(LastDir) - 1, i);
+          m_strcpy(LastDir, sizeof(LastDir), f);
         }
         else {
           getcwd (LastDir, sizeof (LastDir));