[haiku-commits] haiku: hrev45004 - src/apps/mail

  • From: stpere@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 13 Dec 2012 01:44:20 +0100 (CET)

hrev45004 adds 1 changeset to branch 'master'
old head: 4d6bb87ea72eebfcda0c1733788503aa91f067f1
new head: 55ef15c45a831152b1544a28c34de4aa71e151ff
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=55ef15c+%5E4d6bb87

----------------------------------------------------------------------------

55ef15c: Mail: use B_FILE_NAME_LENGTH as limit when saving drafts

                                [ Philippe Saint-Pierre <stpere@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev45004
Commit:      55ef15c45a831152b1544a28c34de4aa71e151ff
URL:         http://cgit.haiku-os.org/haiku/commit/?id=55ef15c
Author:      Philippe Saint-Pierre <stpere@xxxxxxxxx>
Date:        Thu Dec 13 00:41:57 2012 UTC

----------------------------------------------------------------------------

1 file changed, 4 insertions(+), 8 deletions(-)
src/apps/mail/MailWindow.cpp | 12 ++++--------

----------------------------------------------------------------------------

diff --git a/src/apps/mail/MailWindow.cpp b/src/apps/mail/MailWindow.cpp
index 7151aa5..1c246e8 100644
--- a/src/apps/mail/MailWindow.cpp
+++ b/src/apps/mail/MailWindow.cpp
@@ -2548,14 +2548,10 @@ TMailWindow::SaveAsDraft()
                                        return status;
                        case B_OK:
                        {
-                               char fileName[512], *eofn;
-                               int32 i;
-
+                               char fileName[B_FILE_NAME_LENGTH], *eofn;
                                // save as some version of the message's subject
-                               strncpy(fileName, fHeaderView->fSubject->Text(),
-                                       sizeof(fileName)-10);
-                               fileName[sizeof(fileName)-10]='\0';
-                                       // terminate like strncpy doesn't
+                               strlcpy(fileName, fHeaderView->fSubject->Text(),
+                                       sizeof(fileName));
                                eofn = fileName + strlen(fileName);
 
                                // convert /, \ and : to -
@@ -2568,7 +2564,7 @@ TMailWindow::SaveAsDraft()
 
                                // Create the file; if the name exists, find a 
unique name
                                flags = B_WRITE_ONLY | B_CREATE_FILE | 
B_FAIL_IF_EXISTS;
-                               for (i = 1; (status = draft.SetTo(&dir, 
fileName, flags))
+                               for (int32 i = 1; (status = draft.SetTo(&dir, 
fileName, flags))
                                        != B_OK; i++) {
                                        if (status != B_FILE_EXISTS)
                                                return status;


Other related posts:

  • » [haiku-commits] haiku: hrev45004 - src/apps/mail - stpere