summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authoralex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-11-01 12:46:14 +0000
committeralex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-11-01 12:46:14 +0000
commitda4011aa50486b5658e9a78138d2f4891aae18bf (patch)
tree7a00621c9e4459e825a9e75bf0b33819aa358180 /include
parent9a0c02001ca1c35985be6a20e8d3edd63b7730ed (diff)
- introduced secure strcat and strcpy: zbx_strlcat, zbx_strlcpy (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@3423 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'include')
-rw-r--r--include/common.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/include/common.h b/include/common.h
index f5146413..56412132 100644
--- a/include/common.h
+++ b/include/common.h
@@ -26,6 +26,8 @@
#define snprintf ERROR_DO_NOT_USE_SNPRINTF_FUNCTION_TRY_TO_USE_ZBX_SNPRINTF
#define sprintf ERROR_DO_NOT_USE_SPRINTF_FUNCTION_TRY_TO_USE_ZBX_SNPRINTF
+#define strncpy ERROR_DO_NOT_USE_STRNCPY_FUNCTION_TRY_TO_USE_ZBX_STRLCPY
+#define strncat ERROR_DO_NOT_USE_STRNCAT_FUNCTION_TRY_TO_USE_ZBX_STRLCAT
#define ON 1
#define OFF 0
@@ -259,8 +261,7 @@
#endif
/* Secure string copy */
-#define strsncpy(x,y,size) { strncpy(x,y,size); x[size-1]='\0'; }
-#define strscpy(x,y) strsncpy(x,y,sizeof(x))
+#define strscpy(x,y) zbx_strlcpy(x,y,sizeof(x))
#define zbx_free(ptr) { if(ptr){ free(ptr); ptr = NULL; } }
#define zbx_fclose(f) { if(f){ fclose(f); f = NULL; } }
@@ -427,6 +428,8 @@ void zbx_error(const char *fmt, ...);
int zbx_snprintf(char* str, size_t count, const char *fmt, ...);
int set_result_type(AGENT_RESULT *result, int value_type, char *c);
+size_t zbx_strlcpy(char *dst, const char *src, size_t siz);
+size_t zbx_strlcat(char *dst, const char *src, size_t siz);
int replace_param(const char *cmd, const char *param, char *out, int outlen);