@@ -2764,24 +2764,27 @@ static void setProtocolError(const char *errstr, client *c) {
2764
2764
/* Sample some protocol to given an idea about what was inside. */
2765
2765
char buf [256 ];
2766
2766
buf [0 ] = '\0' ;
2767
- if (c -> querybuf && sdslen (c -> querybuf ) - c -> qb_pos < PROTO_DUMP_LEN ) {
2768
- snprintf (buf , sizeof (buf ), "Query buffer during protocol error: '%s'" , c -> querybuf + c -> qb_pos );
2769
- } else if (c -> querybuf ) {
2770
- snprintf (buf , sizeof (buf ), "Query buffer during protocol error: '%.*s' (... more %zu bytes ...) '%.*s'" ,
2771
- PROTO_DUMP_LEN / 2 , c -> querybuf + c -> qb_pos , sdslen (c -> querybuf ) - c -> qb_pos - PROTO_DUMP_LEN ,
2772
- PROTO_DUMP_LEN / 2 , c -> querybuf + sdslen (c -> querybuf ) - PROTO_DUMP_LEN / 2 );
2773
- }
2767
+ if (server .hide_user_data_from_log ) {
2768
+ snprintf (buf , sizeof (buf ), "*redacted*" );
2769
+ } else {
2770
+ if (c -> querybuf && sdslen (c -> querybuf ) - c -> qb_pos < PROTO_DUMP_LEN ) {
2771
+ snprintf (buf , sizeof (buf ), "'%s'" , c -> querybuf + c -> qb_pos );
2772
+ } else if (c -> querybuf ) {
2773
+ snprintf (buf , sizeof (buf ), "'%.*s' (... more %zu bytes ...) '%.*s'" ,
2774
+ PROTO_DUMP_LEN / 2 , c -> querybuf + c -> qb_pos , sdslen (c -> querybuf ) - c -> qb_pos - PROTO_DUMP_LEN ,
2775
+ PROTO_DUMP_LEN / 2 , c -> querybuf + sdslen (c -> querybuf ) - PROTO_DUMP_LEN / 2 );
2776
+ }
2774
2777
2775
- /* Remove non printable chars. */
2776
- char * p = buf ;
2777
- while (* p != '\0' ) {
2778
- if (!isprint (* p )) * p = '.' ;
2779
- p ++ ;
2778
+ /* Remove non printable chars. */
2779
+ char * p = buf ;
2780
+ while (* p != '\0' ) {
2781
+ if (!isprint (* p )) * p = '.' ;
2782
+ p ++ ;
2783
+ }
2780
2784
}
2781
-
2782
2785
/* Log all the client and protocol info. */
2783
2786
int loglevel = (c -> flag .primary ) ? LL_WARNING : LL_VERBOSE ;
2784
- serverLog (loglevel , "Protocol error (%s) from client: %s. %s" , errstr , client , buf );
2787
+ serverLog (loglevel , "Protocol error (%s) from client: %s. Query buffer: %s" , errstr , client , buf );
2785
2788
sdsfree (client );
2786
2789
}
2787
2790
c -> flag .close_after_reply = 1 ;
0 commit comments