@@ -17,8 +17,8 @@ static ngx_rtmp_delete_stream_pt next_delete_stream;
1717
1818static ngx_int_t ngx_rtmp_auto_push_init_process (ngx_cycle_t * cycle );
1919static void ngx_rtmp_auto_push_exit_process (ngx_cycle_t * cycle );
20- static void * ngx_rtmp_auto_push_create_conf (ngx_cycle_t * cf );
21- static char * ngx_rtmp_auto_push_init_conf (ngx_cycle_t * cycle , void * conf );
20+ static void * ngx_rtmp_auto_push_create_conf (ngx_cycle_t * cf );
21+ static char * ngx_rtmp_auto_push_init_conf (ngx_cycle_t * cycle , void * conf );
2222#if (NGX_HAVE_UNIX_DOMAIN )
2323static ngx_int_t ngx_rtmp_auto_push_publish (ngx_rtmp_session_t * s ,
2424 ngx_rtmp_publish_t * v );
@@ -434,6 +434,11 @@ ngx_rtmp_auto_push_create_conf(ngx_cycle_t *cycle)
434434static char *
435435ngx_rtmp_auto_push_init_conf (ngx_cycle_t * cycle , void * conf )
436436{
437+ #if (NGX_HAVE_UNIX_DOMAIN )
438+ struct sockaddr_un saun ;
439+ size_t len ;
440+ u_char * p ;
441+ #endif
437442 ngx_rtmp_auto_push_conf_t * apcf = conf ;
438443
439444 ngx_conf_init_value (apcf -> auto_push , 0 );
@@ -442,6 +447,24 @@ ngx_rtmp_auto_push_init_conf(ngx_cycle_t *cycle, void *conf)
442447 if (apcf -> socket_dir .len == 0 ) {
443448 ngx_str_set (& apcf -> socket_dir , "/tmp" );
444449 }
450+ #if (NGX_HAVE_UNIX_DOMAIN )
451+ else {
452+ p = apcf -> socket_dir .data + apcf -> socket_dir .len - 1 ;
453+
454+ while ((p > apcf -> socket_dir .data ) && (* p == '/' || * p == '\\' )) {
455+ * p -- = '\0' ;
456+ }
457+
458+ apcf -> socket_dir .len = p + 1 - apcf -> socket_dir .data ;
459+ len = apcf -> socket_dir .len + sizeof (NGX_RTMP_AUTO_PUSH_SOCKNAME );
460+
461+ if (len + 1 + NGX_INT_T_LEN >= sizeof (saun .sun_path )) {
462+ ngx_log_error (NGX_LOG_EMERG , cycle -> log , 0 ,
463+ "auto_push: too long \"rtmp_socket_dir\" directive" );
464+ return NGX_CONF_ERROR ;
465+ }
466+ }
467+ #endif
445468
446469 return NGX_CONF_OK ;
447470}
0 commit comments