1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-24 07:40:52 +00:00

Do not use bcmp() to compare two bytes with constants.

This commit is contained in:
Alexander Motin 2008-02-06 20:37:34 +00:00
parent 7035cef466
commit b4d0be220a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=176057
2 changed files with 4 additions and 4 deletions

View File

@ -1399,7 +1399,8 @@ ng_ppp_rcvdata(hook_p hook, item_p item)
/* Strip address and control fields, if present. */
if (m->m_len < 2 && (m = m_pullup(m, 2)) == NULL)
ERROUT(ENOBUFS);
if (bcmp(mtod(m, uint8_t *), &ng_ppp_acf, 2) == 0)
if (mtod(m, uint8_t *)[0] == 0xff &&
mtod(m, uint8_t *)[1] == 0x03)
m_adj(m, 2);
/* Get protocol number */

View File

@ -1179,8 +1179,6 @@ ng_pppoe_rcvdata(hook_p hook, item_p item)
switch (sp->state) {
case PPPOE_NEWCONNECTED:
case PPPOE_CONNECTED: {
static const u_char addrctrl[] = { 0xff, 0x03 };
/*
* Remove PPP address and control fields, if any.
* For example, ng_ppp(4) always sends LCP packets
@ -1190,7 +1188,8 @@ ng_pppoe_rcvdata(hook_p hook, item_p item)
if (m->m_pkthdr.len >= 2) {
if (m->m_len < 2 && !(m = m_pullup(m, 2)))
LEAVE(ENOBUFS);
if (bcmp(mtod(m, u_char *), addrctrl, 2) == 0)
if (mtod(m, u_char *)[0] == 0xff &&
mtod(m, u_char *)[1] == 0x03)
m_adj(m, 2);
}
/*