@@ -1545,20 +1545,25 @@ ngx_stream_upsync_etcd_parse_json(void *data)
15451545static ngx_int_t
15461546ngx_stream_upsync_check_key (u_char * key , ngx_str_t host )
15471547{
1548- u_char * last , * ip_p , * port_p , * s_p ;
1548+ u_char * last , * ip_p , * port_p , * u_p , * s_p ;
15491549 ngx_int_t port ;
15501550
1551- s_p = (u_char * )ngx_strrchr (key , '/' );
1552- if (s_p == NULL ) {
1551+ u_p = (u_char * )ngx_strstr (key , host . data );
1552+ if (u_p == NULL ) {
15531553 ngx_log_error (NGX_LOG_ERR , ngx_cycle -> log , 0 ,
1554- "upsync_parse_json: %s key format is illegal, "
1555- "contains no slash ('/') " , key );
1554+ "upsync_parse_json: %s is illegal, "
1555+ "dont contains upstream name %V " , key , & host );
15561556 return NGX_ERROR ;
15571557 }
1558- if (* (s_p - host .len - 1 ) != '/' ) {
1558+ if (* (u_p + host .len ) != '/' || * ( u_p - 1 ) != '/' ) {
15591559 return NGX_ERROR ;
15601560 }
1561- if (ngx_strncmp ((s_p - host .len ), host .data , host .len ) != 0 ) {
1561+
1562+ s_p = (u_char * )ngx_strrchr (key , '/' );
1563+ if (s_p == NULL ) {
1564+ ngx_log_error (NGX_LOG_ERR , ngx_cycle -> log , 0 ,
1565+ "upsync_parse_json: %s key format is illegal, "
1566+ "contains no slash ('/')" , key );
15621567 return NGX_ERROR ;
15631568 }
15641569
0 commit comments