|
19 | 19 | // Download.cpp : Implementation of CDownload |
20 | 20 | #include "DownloadDebug.h" |
21 | 21 | #include "Download.h" |
| 22 | +#include "stringex.h" |
22 | 23 | #include <mmsystem.h> |
23 | 24 | #include <assert.h> |
24 | 25 | #include <direct.h> |
@@ -69,15 +70,15 @@ HRESULT CDownload::DownloadFile(LPCSTR server, LPCSTR username, LPCSTR password, |
69 | 70 | _mkdir("download"); |
70 | 71 |
|
71 | 72 | // Copy parameters to member variables. |
72 | | - strncpy( m_Server, server, sizeof( m_Server ) ); |
73 | | - strncpy( m_Login, username, sizeof( m_Login ) ); |
74 | | - strncpy( m_Password, password, sizeof( m_Password ) ); |
75 | | - strncpy( m_File, file, sizeof( m_File ) ); |
76 | | - strncpy( m_LocalFile, localfile, sizeof( m_LocalFile ) ); |
| 73 | + strlcpy( m_Server, server, sizeof( m_Server ) ); |
| 74 | + strlcpy( m_Login, username, sizeof( m_Login ) ); |
| 75 | + strlcpy( m_Password, password, sizeof( m_Password ) ); |
| 76 | + strlcpy( m_File, file, sizeof( m_File ) ); |
| 77 | + strlcpy( m_LocalFile, localfile, sizeof( m_LocalFile ) ); |
77 | 78 |
|
78 | | - strncpy( m_LastLocalFile, localfile, sizeof( m_LastLocalFile ) ); |
| 79 | + strlcpy( m_LastLocalFile, localfile, sizeof( m_LastLocalFile ) ); |
79 | 80 |
|
80 | | - strncpy( m_RegKey, regkey, sizeof( m_RegKey ) ); |
| 81 | + strlcpy( m_RegKey, regkey, sizeof( m_RegKey ) ); |
81 | 82 | m_TryResume = tryresume; |
82 | 83 | m_StartPosition=0; |
83 | 84 |
|
@@ -113,8 +114,7 @@ HRESULT CDownload::GetLastLocalFile(char *local_file, int maxlen) { |
113 | 114 | if (local_file==0) |
114 | 115 | return(E_FAIL); |
115 | 116 |
|
116 | | - strncpy(local_file, m_LastLocalFile, maxlen); |
117 | | - local_file[maxlen-1]=0; |
| 117 | + strlcpy(local_file, m_LastLocalFile, maxlen); |
118 | 118 |
|
119 | 119 | return(S_OK); |
120 | 120 | } |
|
0 commit comments