Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 219750
Collapse All | Expand All

(-)src/init.c (-21 / +21 lines)
Lines 1030-1067 Link Here
1030
    /*
1030
    /*
1031
     * Open display, get options/resources and create the window
1031
     * Open display, get options/resources and create the window
1032
     */
1032
     */
1033
    if (IS_NULL(rs[Rs_display_name] = getenv("DISPLAY")))
1034
	rs[Rs_display_name] = ":0";
1035
1036
    rxvt_get_options( r, r_argc, r_argv );
1033
    rxvt_get_options( r, r_argc, r_argv );
1037
    rxvt_free( r_argv ); /* XXX memory leak? */
1034
    rxvt_free( r_argv ); /* XXX memory leak? */
1038
1035
1039
#ifdef LOCAL_X_IS_UNIX
1036
#ifdef LOCAL_X_IS_UNIX
1040
    if( rs[Rs_display_name][0] == ':' )
1037
    /*
1038
     * 2008-04-29 gi1242: Force UNIX sockets for security (Gentoo Bug #219750)
1039
     */
1040
    if( IS_NULL( rs[Rs_display_name] ) )
1041
	rs[Rs_display_name] = getenv( "DISPLAY" );
1042
1043
    if( rs[Rs_display_name] && rs[Rs_display_name][0] == ':' )
1041
    {
1044
    {
1042
	int	l = 5 + STRLEN(rs[Rs_display_name]);
1045
	char *val;
1046
	int l = 5 + STRLEN(rs[Rs_display_name]);
1043
	if (l <= 0 || l > 1024) /* possible integer overflow */
1047
	if (l <= 0 || l > 1024) /* possible integer overflow */
1044
	    l = 1024;
1048
	    l = 1024;
1049
1045
	val = rxvt_malloc(l);
1050
	val = rxvt_malloc(l);
1046
	STRCPY(val, "unix");
1051
	STRCPY( val, "unix");
1047
	STRNCAT(val, rs[Rs_display_name], l-5);
1052
	STRNCAT( val, rs[Rs_display_name], l-5);
1048
	val[l-1] = (char) 0;
1053
1049
	rxvt_msg (DBG_INFO, DBG_INIT, "Open X display %s\n", val);
1054
	rs[Rs_display_name] = val;
1050
	r->Xdisplay = XOpenDisplay(val);
1051
	rxvt_free(val);
1052
    }
1055
    }
1053
#endif
1056
#endif /* LOCAL_X_IS_UNIX */
1054
1057
1055
    if (IS_NULL(r->Xdisplay))
1058
    rxvt_msg( DBG_INFO, DBG_INIT, "Open X display %s\n", rs[Rs_display_name] );
1059
    r->Xdisplay = XOpenDisplay( rs[Rs_display_name] );
1060
    if( IS_NULL(r->Xdisplay) )
1056
    {
1061
    {
1057
	rxvt_msg (DBG_INFO, DBG_INIT, "Open X display %s\n",
1062
	rxvt_msg( DBG_ERROR, DBG_INIT, "Error opening display %s\n",
1058
		    rs[Rs_display_name] ? rs[Rs_display_name] : "nil");
1063
		rs[Rs_display_name] );
1059
	r->Xdisplay = XOpenDisplay( rs[Rs_display_name] );
1064
	exit( EXIT_FAILURE );
1060
	if (IS_NULL(r->Xdisplay))
1061
	{
1062
	    rxvt_msg (DBG_ERROR, DBG_INIT,  "can't open display %s", rs[Rs_display_name] );
1063
	    exit( EXIT_FAILURE );
1064
	}
1065
    }
1065
    }
1066
1066
1067
1067

Return to bug 219750