Skip to content

Commit

Permalink
Mail: use B_FILE_NAME_LENGTH as limit when saving drafts
Browse files Browse the repository at this point in the history
  • Loading branch information
stpere committed Dec 13, 2012
1 parent 4d6bb87 commit 55ef15c
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/apps/mail/MailWindow.cpp
Expand Up @@ -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 -
Expand All @@ -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;
Expand Down

0 comments on commit 55ef15c

Please sign in to comment.