Ignore:
Timestamp:
29/03/2009 14:51:24 (3 years ago)
Author:
chris
Message:

Change type of BackupStoreFilename? not to derive from std::string, so
it can't accidentally be used as one.

Fix use of encrypted filename in deleted file message, thanks to Kenny
Millington for reporting.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/lib/backupclient/BackupStoreFilenameClear.cpp

    r2127 r2481  
    161161                 
    162162        // Decode the header 
    163         int size = BACKUPSTOREFILENAME_GET_SIZE(*this); 
    164         int encoding = BACKUPSTOREFILENAME_GET_ENCODING(*this); 
     163        int size = BACKUPSTOREFILENAME_GET_SIZE(GetEncodedFilename()); 
     164        int encoding = BACKUPSTOREFILENAME_GET_ENCODING(GetEncodedFilename()); 
    165165         
    166166        // Decode based on encoding given in the header 
     
    170170                BOX_TRACE("**** BackupStoreFilename encoded with " 
    171171                        "Clear encoding ****"); 
    172                 mClearFilename.assign(c_str() + 2, size - 2); 
     172                mClearFilename.assign(GetEncodedFilename().c_str() + 2, 
     173                        size - 2); 
    173174                break; 
    174175                 
     
    245246         
    246247        // Store the encoded string 
    247         assign((char*)buffer, encSize); 
     248        SetEncodedFilename(std::string((char*)buffer, encSize)); 
    248249} 
    249250 
     
    259260void BackupStoreFilenameClear::DecryptEncoded(CipherContext &rCipherContext) const 
    260261{ 
     262        const std::string& rEncoded = GetEncodedFilename(); 
     263 
    261264        // Work out max size 
    262         int maxOutSize = rCipherContext.MaxOutSizeForInBufferSize(size()) + 4; 
     265        int maxOutSize = rCipherContext.MaxOutSizeForInBufferSize(rEncoded.size()) + 4; 
    263266         
    264267        // Make sure encode/decode buffer has enough space 
     
    269272         
    270273        // Decrypt 
    271         const char *str = c_str() + 2; 
    272         int sizeOut = rCipherContext.TransformBlock(buffer, sEncDecBufferSize, str, size() - 2); 
     274        const char *str = rEncoded.c_str() + 2; 
     275        int sizeOut = rCipherContext.TransformBlock(buffer, sEncDecBufferSize, str, rEncoded.size() - 2); 
    273276         
    274277        // Assign to this 
Note: See TracChangeset for help on using the changeset viewer.