@@ -205,6 +205,7 @@ static void connection_event_handler(int incoming_sd, short flags, void* cbdata)
205205static int component_startup (void )
206206{
207207 int rc = ORTE_SUCCESS ;
208+ char * usock_path ;
208209
209210 opal_output_verbose (2 , orte_oob_base_framework .framework_output ,
210211 "%s USOCK STARTUP" ,
@@ -213,11 +214,29 @@ static int component_startup(void)
213214 /* setup the path to the daemon rendezvous point */
214215 memset (& mca_oob_usock_component .address , 0 , sizeof (struct sockaddr_un ));
215216 mca_oob_usock_component .address .sun_family = AF_UNIX ;
216- snprintf (mca_oob_usock_component .address .sun_path ,
217- sizeof (mca_oob_usock_component .address .sun_path )- 1 ,
217+ asprintf (& usock_path ,
218218 "%s/%s/%s/0/%s" , orte_process_info .tmpdir_base ,
219219 orte_process_info .top_session_dir ,
220220 ORTE_JOB_FAMILY_PRINT (ORTE_PROC_MY_NAME -> jobid ), "usock" );
221+ if (NULL == usock_path ) {
222+ rc = ORTE_ERR_OUT_OF_RESOURCE ;
223+ ORTE_ERROR_LOG (rc );
224+ }
225+
226+ /* If usock_path is too long, just fail, so the caller
227+ * may provide the user with a proper help... *Cough*, *Cough* OSX... */
228+ if ((strlen (usock_path ) + 1 ) > sizeof (mca_oob_usock_component .address .sun_path )) {
229+ opal_output_verbose (2 , orte_oob_base_framework .framework_output ,
230+ "usock path too long: strlen(%s) > %d\nyou might want to check you $TMPDIR or $TMP environment variable" ,
231+ usock_path , (int )sizeof (mca_oob_usock_component .address .sun_path )- 1 );
232+ free (usock_path );
233+ return ORTE_ERR_NOT_SUPPORTED ;
234+
235+ }
236+
237+ strncpy (mca_oob_usock_component .address .sun_path , usock_path , sizeof (mca_oob_usock_component .address .sun_path )- 1 );
238+ free (usock_path );
239+
221240 opal_output_verbose (2 , orte_oob_base_framework .framework_output ,
222241 "SUNPATH: %s" , mca_oob_usock_component .address .sun_path );
223242
0 commit comments