freebsd-skq/contrib/ntp/ntpd/rc_cmdlength.c
glebius 9163b6ba3b MFV ntp-4.2.8p4 (r289715)
Security:       VuXML: c4a18a12-77fc-11e5-a687-206a8a720317
Security:	CVE-2015-7871
Security:	CVE-2015-7855
Security:	CVE-2015-7854
Security:	CVE-2015-7853
Security:	CVE-2015-7852
Security:	CVE-2015-7851
Security:	CVE-2015-7850
Security:	CVE-2015-7849
Security:	CVE-2015-7848
Security:	CVE-2015-7701
Security:	CVE-2015-7703
Security:	CVE-2015-7704, CVE-2015-7705
Security:	CVE-2015-7691, CVE-2015-7692, CVE-2015-7702
Security:	http://support.ntp.org/bin/view/Main/SecurityNotice#October_2015_NTP_Security_Vulner
Sponsored by:	Nginx, Inc.
2015-10-22 19:42:57 +00:00

37 lines
716 B
C

#include <config.h>
#include <rc_cmdlength.h>
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
/* Bug 2853 */
/* evaluate the length of the command sequence. This breaks at the first
* char that is not >= SPACE and <= 127 after trimming from the right.
*/
size_t
remoteconfig_cmdlength(
const char *src_buf,
const char *src_end
)
{
const char *scan;
unsigned char ch;
/* trim whitespace & garbage from the right */
while (src_end != src_buf) {
ch = src_end[-1];
if (ch > ' ' && ch < 128)
break;
--src_end;
}
/* now do a forward scan */
for (scan = src_buf; scan != src_end; ++scan) {
ch = scan[0];
if ((ch < ' ' || ch >= 128) && ch != '\t')
break;
}
return (size_t)(scan - src_buf);
}