mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
r13788@catbus: nickm | 2007-07-16 14:26:25 -0400
Patch from croup: rewrite the logic of get_next_token() to do the right thing with input that ends at weird places, or aligns with block boundaries after mmap. should fix bug 455. Needs fuzzing. svn:r10847
This commit is contained in:
@@ -1730,7 +1730,6 @@ tor_threads_init(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* On Windows, WSAEWOULDBLOCK is not always correct: when you see it,
|
||||
* you need to ask the socket for its actual errno. Also, you need to
|
||||
|
||||
+20
-4
@@ -403,6 +403,21 @@ strcmpstart(const char *s1, const char *s2)
|
||||
return strncmp(s1, s2, n);
|
||||
}
|
||||
|
||||
/** Compare the s1_len-byte string <b>s1</b> with <b>s2</b>,
|
||||
* without depending on a terminating nul in s1. Sorting order is first by
|
||||
* length, then lexically; return values are as for strcmp.
|
||||
*/
|
||||
int
|
||||
strcmp_len(const char *s1, const char *s2, size_t s1_len)
|
||||
{
|
||||
size_t s2_len = strlen(s2);
|
||||
if (s1_len < s2_len)
|
||||
return -1;
|
||||
if (s1_len > s2_len)
|
||||
return 1;
|
||||
return memcmp(s1, s2, s2_len);
|
||||
}
|
||||
|
||||
/** Compares the first strlen(s2) characters of s1 with s2. Returns as for
|
||||
* strcasecmp.
|
||||
*/
|
||||
@@ -505,7 +520,8 @@ eat_whitespace_no_nl(const char *s)
|
||||
return s;
|
||||
}
|
||||
|
||||
/** DOCDOC */
|
||||
/** As eat_whitespace_no_nl, but stop at <b>eos</b> whether we have
|
||||
* found a non-whitespace character or not. */
|
||||
const char *
|
||||
eat_whitespace_eos_no_nl(const char *s, const char *eos)
|
||||
{
|
||||
@@ -537,7 +553,8 @@ find_whitespace(const char *s)
|
||||
}
|
||||
}
|
||||
|
||||
/** DOCDOC */
|
||||
/** As find_whitespace, but stop at <b>eos</b> whether we have found a
|
||||
* whitespace or not. */
|
||||
const char *
|
||||
find_whitespace_eos(const char *s, const char *eos)
|
||||
{
|
||||
@@ -556,10 +573,9 @@ find_whitespace_eos(const char *s, const char *eos)
|
||||
++s;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
/** Return true iff the 'len' bytes at 'mem' are all zero. */
|
||||
int
|
||||
tor_mem_is_zero(const char *mem, size_t len)
|
||||
|
||||
@@ -155,6 +155,8 @@ void tor_strupper(char *s) ATTR_NONNULL((1));
|
||||
int tor_strisprint(const char *s) ATTR_PURE ATTR_NONNULL((1));
|
||||
int tor_strisnonupper(const char *s) ATTR_PURE ATTR_NONNULL((1));
|
||||
int strcmpstart(const char *s1, const char *s2) ATTR_PURE ATTR_NONNULL((1,2));
|
||||
int strcmp_len(const char *s1, const char *s2, size_t len)
|
||||
ATTR_PURE ATTR_NONNULL((1,2));
|
||||
int strcasecmpstart(const char *s1, const char *s2)
|
||||
ATTR_PURE ATTR_NONNULL((1,2));
|
||||
int strcmpend(const char *s1, const char *s2) ATTR_PURE ATTR_NONNULL((1,2));
|
||||
|
||||
Reference in New Issue
Block a user