diff options
author | George Hazan <george.hazan@gmail.com> | 2015-05-28 15:43:44 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-05-28 15:43:44 +0000 |
commit | 7666c2ce26dd9a6e2fb129dea4d2fad9bcdbe591 (patch) | |
tree | e6fa63a806ef6e62e06ec56177a02898a9db9d6f /plugins/YahooGroups | |
parent | b894583716289087a7144fd770d1a5f96bca82cd (diff) |
unsafe strncat removed
git-svn-id: http://svn.miranda-ng.org/main/trunk@13874 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/YahooGroups')
-rw-r--r-- | plugins/YahooGroups/src/commonheaders.h | 1 | ||||
-rw-r--r-- | plugins/YahooGroups/src/list.cpp | 4 | ||||
-rw-r--r-- | plugins/YahooGroups/src/list.h | 4 | ||||
-rw-r--r-- | plugins/YahooGroups/src/services.cpp | 43 |
4 files changed, 19 insertions, 33 deletions
diff --git a/plugins/YahooGroups/src/commonheaders.h b/plugins/YahooGroups/src/commonheaders.h index 61d51f6236..db316c3b18 100644 --- a/plugins/YahooGroups/src/commonheaders.h +++ b/plugins/YahooGroups/src/commonheaders.h @@ -34,6 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_options.h>
#include <m_protosvc.h>
#include <m_popup.h>
+#include <m_string.h>
#include <win2k.h>
#include "version.h"
diff --git a/plugins/YahooGroups/src/list.cpp b/plugins/YahooGroups/src/list.cpp index 364f468926..abfde10670 100644 --- a/plugins/YahooGroups/src/list.cpp +++ b/plugins/YahooGroups/src/list.cpp @@ -86,12 +86,12 @@ int CGroupsList::Count() return count;
}
-int CGroupsList::Contains(char *group)
+int CGroupsList::Contains(const char *group)
{
return (Index(group) >= 0);
}
-int CGroupsList::Index(char *group)
+int CGroupsList::Index(const char *group)
{
int i;
for (i = 0; i < count; i++)
diff --git a/plugins/YahooGroups/src/list.h b/plugins/YahooGroups/src/list.h index ef34699e7c..3414d8fdec 100644 --- a/plugins/YahooGroups/src/list.h +++ b/plugins/YahooGroups/src/list.h @@ -42,8 +42,8 @@ class CGroupsList int Count();
- int Contains(char *group);
- int Index(char *group);
+ int Contains(const char *group);
+ int Index(const char *group);
char *operator [](int index);
};
diff --git a/plugins/YahooGroups/src/services.cpp b/plugins/YahooGroups/src/services.cpp index a5a0b01cfd..f13cd473ff 100644 --- a/plugins/YahooGroups/src/services.cpp +++ b/plugins/YahooGroups/src/services.cpp @@ -87,7 +87,7 @@ int GetNextGroupIndex() return index - 1;
}
-void AddNewGroup(char *newGroup)
+void AddNewGroup(const char *newGroup)
{
int index = GetNextGroupIndex();
@@ -119,44 +119,29 @@ void CreateGroup(char *group) {
char *p = group;
char *sub = group;
- char buffer[1024] = {0};
-
+
+ CMStringA buf;
while ((p = strchr(sub, '\\')))
{
*p = 0;
- if (mir_strlen(buffer) > 0)
- {
- mir_strncat(buffer, "\\", SIZEOF(buffer) - mir_strlen(buffer));
- mir_strncat(buffer, sub, SIZEOF(buffer) - mir_strlen(buffer));
- }
- else{
- strncpy_s(buffer, sub, _TRUNCATE);
- }
+ if (!buf.IsEmpty())
+ buf.AppendChar('\\');
+ buf.Append(sub);
- if (!availableGroups.Contains(buffer))
- {
- AddNewGroup(buffer);
- }
+ if (!availableGroups.Contains(buf))
+ AddNewGroup(buf);
*p++ = '\\';
sub = p;
}
- if (sub)
- {
- if (mir_strlen(buffer) > 0)
- {
- mir_strncat(buffer, "\\", SIZEOF(buffer) - mir_strlen(buffer));
- mir_strncat(buffer, sub, SIZEOF(buffer) - mir_strlen(buffer));
- }
- else{
- strncpy_s(buffer, sub, _TRUNCATE);
- }
+ if (sub) {
+ if (!buf.IsEmpty())
+ buf.AppendChar('\\');
+ buf.Append(sub);
- if (!availableGroups.Contains(buffer))
- {
- AddNewGroup(buffer);
- }
+ if (!availableGroups.Contains(buf))
+ AddNewGroup(buf);
}
}
|