forked from github/server
never use strncpy, anywhere.
This commit is contained in:
parent
9463642687
commit
8d02d5a5aa
|
@ -3,6 +3,7 @@
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include <kernel/config.h>
|
#include <kernel/config.h>
|
||||||
#include <kernel/jsonconf.h>
|
#include <kernel/jsonconf.h>
|
||||||
|
#include <util/bsdstring.h>
|
||||||
#include <util/log.h>
|
#include <util/log.h>
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
#include <cJSON.h>
|
#include <cJSON.h>
|
||||||
|
@ -45,7 +46,7 @@ int config_parse(const char *json)
|
||||||
if (xp >= ep) break;
|
if (xp >= ep) break;
|
||||||
}
|
}
|
||||||
xp = (ep > json + 10) ? ep - 10 : json;
|
xp = (ep > json + 10) ? ep - 10 : json;
|
||||||
strncpy(buffer, xp, sizeof(buffer));
|
strlcpy(buffer, xp, sizeof(buffer));
|
||||||
buffer[9] = 0;
|
buffer[9] = 0;
|
||||||
log_error("json parse error in line %d, position %d, near `%s`\n", line, ep - lp, buffer);
|
log_error("json parse error in line %d, position %d, near `%s`\n", line, ep - lp, buffer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,7 @@ static int lua_callspell(castorder * co)
|
||||||
if (hashpos != NULL) {
|
if (hashpos != NULL) {
|
||||||
ptrdiff_t len = hashpos - fname;
|
ptrdiff_t len = hashpos - fname;
|
||||||
assert(len < (ptrdiff_t) sizeof(fbuf));
|
assert(len < (ptrdiff_t) sizeof(fbuf));
|
||||||
strncpy(fbuf, fname, len);
|
memcpy(fbuf, fname, len);
|
||||||
fbuf[len] = '\0';
|
fbuf[len] = '\0';
|
||||||
fname = fbuf;
|
fname = fbuf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ void log_string(void *data, int level, const char *module, const char *format, v
|
||||||
unused_arg(format);
|
unused_arg(format);
|
||||||
unused_arg(module);
|
unused_arg(module);
|
||||||
unused_arg(level);
|
unused_arg(level);
|
||||||
strncpy(str, arg, 32);
|
strcpy(str, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_logging(CuTest * tc)
|
static void test_logging(CuTest * tc)
|
||||||
|
|
Loading…
Reference in New Issue