mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-25 04:17:42 +00:00
[MINOR] halog: do not consider byte 0x8A as end of line
A bug in the algorithm used to find an LF in multiple bytes at once made byte 0x80 trigger detection of byte 0x00, thus 0x8A matches byte 0x0A. In practice, this issue never happens since byte 0x8A won't be displayed in logs (or it will be encoded). This could still possibly happen in mixed logs.
This commit is contained in:
parent
52b2d228ed
commit
96c148b0d2
contrib/halog
@ -21,7 +21,7 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// return 1 if the integer contains at least one zero byte
|
||||
// return non-zero if the integer contains at least one zero byte
|
||||
static inline unsigned int has_zero(unsigned int x)
|
||||
{
|
||||
unsigned int y;
|
||||
@ -38,25 +38,21 @@ static inline unsigned int has_zero(unsigned int x)
|
||||
* we check in the final result if one of them is present and was not.
|
||||
*/
|
||||
y = x;
|
||||
x = ~x & 0x80808080; /* save and invert bits 7, 15, 23, 31 */
|
||||
y &= 0x7F7F7F7F; /* clear them */
|
||||
y -= 0x01010101; /* generate a carry */
|
||||
y &= x; /* clear the bits that were already set */
|
||||
return !!y;
|
||||
y -= 0x01010101; /* generate a carry */
|
||||
y &= ~x; /* clear the bits that were already set */
|
||||
return y & 0x80808080;
|
||||
}
|
||||
|
||||
|
||||
// return 1 if the argument contains at least one zero byte. See principle above.
|
||||
static inline unsigned int has_zero64(unsigned long long x)
|
||||
// return non-zero if the argument contains at least one zero byte. See principle above.
|
||||
static inline unsigned long long has_zero64(unsigned long long x)
|
||||
{
|
||||
unsigned long long y;
|
||||
|
||||
y = x;
|
||||
x = ~x & 0x8080808080808080ULL; /* save bits 7, 15, 23, 31, 39, 47, 55 and 63 */
|
||||
y &= 0x7F7F7F7F7F7F7F7FULL; /* clear them */
|
||||
y -= 0x0101010101010101ULL; /* generate a carry */
|
||||
y &= x; /* clear the bits that were already set */
|
||||
return !!y;
|
||||
y &= ~x; /* clear the bits that were already set */
|
||||
return y & 0x8080808080808080ULL;
|
||||
}
|
||||
|
||||
#define FGETS2_BUFSIZE (256*1024)
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// return 1 if the integer contains at least one zero byte
|
||||
// return non-zero if the integer contains at least one zero byte
|
||||
static inline unsigned int has_zero(unsigned int x)
|
||||
{
|
||||
unsigned int y;
|
||||
@ -38,11 +38,9 @@ static inline unsigned int has_zero(unsigned int x)
|
||||
* we check in the final result if one of them is present and was not.
|
||||
*/
|
||||
y = x;
|
||||
x = ~x & 0x80808080; /* save and invert bits 7, 15, 23, 31 */
|
||||
y &= 0x7F7F7F7F; /* clear them */
|
||||
y -= 0x01010101; /* generate a carry */
|
||||
y &= x; /* clear the bits that were already set */
|
||||
return !!y;
|
||||
y &= ~x; /* clear the bits that were already set */
|
||||
return y & 0x80808080;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user