lsock_init_port: address issues with initializing sockaddr_un object
- Use strlcpy to ensure p->name doesn't overflow sa.sun_path [*]. - Use SUN_LEN(..) instead of spelling out calculation longhand (inspired by comment by jmallett). Tested with: dgram and stream support with both bsnmpwalk and snmpwalk MFC after: 1 week Reported by: Coverity CID: 1006825
This commit is contained in:
parent
10a0306a2e
commit
70157df618
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=311381
@ -308,10 +308,9 @@ lsock_init_port(struct tport *tp)
|
|||||||
return (SNMP_ERR_RES_UNAVAIL);
|
return (SNMP_ERR_RES_UNAVAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(sa.sun_path, p->name);
|
strlcpy(sa.sun_path, p->name, sizeof(sa.sun_path));
|
||||||
sa.sun_family = AF_LOCAL;
|
sa.sun_family = AF_LOCAL;
|
||||||
sa.sun_len = strlen(p->name) +
|
sa.sun_len = SUN_LEN(&sa);
|
||||||
offsetof(struct sockaddr_un, sun_path);
|
|
||||||
|
|
||||||
(void)remove(p->name);
|
(void)remove(p->name);
|
||||||
|
|
||||||
@ -363,10 +362,9 @@ lsock_init_port(struct tport *tp)
|
|||||||
return (SNMP_ERR_GENERR);
|
return (SNMP_ERR_GENERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(sa.sun_path, p->name);
|
strlcpy(sa.sun_path, p->name, sizeof(sa.sun_path));
|
||||||
sa.sun_family = AF_LOCAL;
|
sa.sun_family = AF_LOCAL;
|
||||||
sa.sun_len = strlen(p->name) +
|
sa.sun_len = SUN_LEN(&sa);
|
||||||
offsetof(struct sockaddr_un, sun_path);
|
|
||||||
|
|
||||||
(void)remove(p->name);
|
(void)remove(p->name);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user