fix: replace unsafe function
This commit is contained in:
parent
d239d3b5b2
commit
0aae99ca8f
|
@ -288,7 +288,7 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (SCH_IS_DATA_SRC_TASK(task) && job->dataSrcEps.numOfEps < SCH_MAX_CANDIDATE_EP_NUM) {
|
if (SCH_IS_DATA_SRC_TASK(task) && job->dataSrcEps.numOfEps < SCH_MAX_CANDIDATE_EP_NUM) {
|
||||||
strncpy(job->dataSrcEps.fqdn[job->dataSrcEps.numOfEps], task->execAddr.fqdn, sizeof(task->execAddr.fqdn));
|
tstrncpy(job->dataSrcEps.fqdn[job->dataSrcEps.numOfEps], task->execAddr.fqdn, sizeof(task->execAddr.fqdn));
|
||||||
job->dataSrcEps.port[job->dataSrcEps.numOfEps] = task->execAddr.port;
|
job->dataSrcEps.port[job->dataSrcEps.numOfEps] = task->execAddr.port;
|
||||||
|
|
||||||
++job->dataSrcEps.numOfEps;
|
++job->dataSrcEps.numOfEps;
|
||||||
|
@ -840,7 +840,7 @@ int32_t schSetTaskCandidateAddrs(SSchJob *pJob, SSchTask *pTask) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
for (int32_t i = 0; i < job->dataSrcEps.numOfEps && addNum < SCH_MAX_CANDIDATE_EP_NUM; ++i) {
|
for (int32_t i = 0; i < job->dataSrcEps.numOfEps && addNum < SCH_MAX_CANDIDATE_EP_NUM; ++i) {
|
||||||
strncpy(epSet->fqdn[epSet->numOfEps], job->dataSrcEps.fqdn[i], sizeof(job->dataSrcEps.fqdn[i]));
|
tstrncpy(epSet->fqdn[epSet->numOfEps], job->dataSrcEps.fqdn[i], sizeof(job->dataSrcEps.fqdn[i]));
|
||||||
epSet->port[epSet->numOfEps] = job->dataSrcEps.port[i];
|
epSet->port[epSet->numOfEps] = job->dataSrcEps.port[i];
|
||||||
|
|
||||||
++epSet->numOfEps;
|
++epSet->numOfEps;
|
||||||
|
|
|
@ -341,7 +341,7 @@ int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (full_path.we_wordv != NULL && full_path.we_wordv[0] != NULL) {
|
if (full_path.we_wordv != NULL && full_path.we_wordv[0] != NULL) {
|
||||||
(void)strncpy(outname, full_path.we_wordv[0], maxlen);
|
tstrncpy(outname, full_path.we_wordv[0], maxlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
wordfree(&full_path);
|
wordfree(&full_path);
|
||||||
|
@ -358,9 +358,9 @@ int32_t taosRealPath(char *dirname, char *realPath, int32_t maxlen) {
|
||||||
#endif
|
#endif
|
||||||
if (strlen(tmp) < maxlen) {
|
if (strlen(tmp) < maxlen) {
|
||||||
if (realPath == NULL) {
|
if (realPath == NULL) {
|
||||||
(void)strncpy(dirname, tmp, maxlen);
|
tstrncpy(dirname, tmp, maxlen);
|
||||||
} else {
|
} else {
|
||||||
(void)strncpy(realPath, tmp, maxlen);
|
tstrncpy(realPath, tmp, maxlen);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -559,6 +559,6 @@ void taosGetCwd(char *buf, int32_t len) {
|
||||||
char *unused __attribute__((unused));
|
char *unused __attribute__((unused));
|
||||||
unused = getcwd(buf, len - 1);
|
unused = getcwd(buf, len - 1);
|
||||||
#else
|
#else
|
||||||
strncpy(buf, "not implemented on windows", len - 1);
|
tstrncpy(buf, "not implemented on windows", len);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ void taosGetSystemLocale(char *outLocale, char *outCharset) {
|
||||||
char *revisedCharset = taosCharsetReplace(str);
|
char *revisedCharset = taosCharsetReplace(str);
|
||||||
|
|
||||||
if (NULL == revisedCharset) {
|
if (NULL == revisedCharset) {
|
||||||
(void)tstrncpy(outCharset, "UTF-8", TD_CHARSET_LEN);
|
tstrncpy(outCharset, "UTF-8", TD_CHARSET_LEN);
|
||||||
} else {
|
} else {
|
||||||
tstrncpy(outCharset, revisedCharset, TD_CHARSET_LEN);
|
tstrncpy(outCharset, revisedCharset, TD_CHARSET_LEN);
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ char *taosStrndup(const char *s, int size) {
|
||||||
if (l > size) l = size;
|
if (l > size) l = size;
|
||||||
s2 = malloc(l + 1);
|
s2 = malloc(l + 1);
|
||||||
if (s2) {
|
if (s2) {
|
||||||
strncpy(s2, s, l);
|
tstrncpy(s2, s, l + 1);
|
||||||
s2[l] = '\0';
|
s2[l] = '\0';
|
||||||
} else {
|
} else {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
Loading…
Reference in New Issue