pluto: Replaced some strcpy usages with strncpy.
This commit is contained in:
parent
81b598ca5f
commit
6e0c82141f
|
@ -77,7 +77,7 @@ size_t dstlen;
|
||||||
break; /* NOTE BREAK OUT */
|
break; /* NOTE BREAK OUT */
|
||||||
}
|
}
|
||||||
if (pre == NULL) { /* unknown protocol */
|
if (pre == NULL) { /* unknown protocol */
|
||||||
strcpy(unk, "unk");
|
strncpy(unk, "unk", sizeof(unk));
|
||||||
(void) ultot((unsigned char)sa->proto, 10, unk+strlen(unk),
|
(void) ultot((unsigned char)sa->proto, 10, unk+strlen(unk),
|
||||||
sizeof(unk)-strlen(unk));
|
sizeof(unk)-strlen(unk));
|
||||||
pre = unk;
|
pre = unk;
|
||||||
|
@ -86,9 +86,9 @@ size_t dstlen;
|
||||||
if (strcmp(pre, PASSTHROUGHTYPE) == 0 &&
|
if (strcmp(pre, PASSTHROUGHTYPE) == 0 &&
|
||||||
sa->spi == PASSTHROUGHSPI &&
|
sa->spi == PASSTHROUGHSPI &&
|
||||||
isunspecaddr(&sa->dst)) {
|
isunspecaddr(&sa->dst)) {
|
||||||
strcpy(buf, (addrtypeof(&sa->dst) == AF_INET) ?
|
strncpy(buf, (addrtypeof(&sa->dst) == AF_INET) ?
|
||||||
PASSTHROUGH4NAME :
|
PASSTHROUGH4NAME :
|
||||||
PASSTHROUGH6NAME);
|
PASSTHROUGH6NAME, sizeof(buf));
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,13 +104,13 @@ size_t dstlen;
|
||||||
default: p = NULL; break;
|
default: p = NULL; break;
|
||||||
}
|
}
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
strcpy(buf, p);
|
strncpy(buf, p, sizeof(buf));
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len == 0) { /* general case needed */
|
if (len == 0) { /* general case needed */
|
||||||
strcpy(buf, pre);
|
strncpy(buf, pre, sizeof(buf));
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
if (showversion) {
|
if (showversion) {
|
||||||
*(buf+len) = (addrtypeof(&sa->dst) == AF_INET) ? '.' :
|
*(buf+len) = (addrtypeof(&sa->dst) == AF_INET) ? '.' :
|
||||||
|
@ -126,7 +126,7 @@ size_t dstlen;
|
||||||
if (dst != NULL) {
|
if (dst != NULL) {
|
||||||
if (len > dstlen)
|
if (len > dstlen)
|
||||||
*(buf+dstlen-1) = '\0';
|
*(buf+dstlen-1) = '\0';
|
||||||
strcpy(dst, buf);
|
strncpy(dst, buf, dstlen);
|
||||||
}
|
}
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
|
@ -673,7 +673,7 @@ size_t format_end(char *buf, size_t buf_len, const struct end *this,
|
||||||
}
|
}
|
||||||
else if (subnetisnone(&this->client))
|
else if (subnetisnone(&this->client))
|
||||||
{
|
{
|
||||||
strcpy(client, "?");
|
strncpy(client, "?", sizeof(client));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -685,7 +685,7 @@ size_t format_end(char *buf, size_t buf_len, const struct end *this,
|
||||||
/* we are mode config client, or a server with a pool */
|
/* we are mode config client, or a server with a pool */
|
||||||
client_sep = "===";
|
client_sep = "===";
|
||||||
client[0] = '%';
|
client[0] = '%';
|
||||||
strcpy(client+1, this->pool ? this->pool : "modecfg");
|
strncpy(client+1, this->pool ?: "modecfg", sizeof(client)-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* host */
|
/* host */
|
||||||
|
|
Loading…
Reference in New Issue