From: Paul Eggert Date: Tue, 21 Jun 2011 20:32:19 +0000 (-0700) Subject: * xsmfns.c (smc_save_yourself_CB, x_session_initialize): Avoid strlen. X-Git-Tag: emacs-pretest-24.0.90~104^2~473^2~6 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2606c57bbfd45c35357483e9fa39035ee8953cab;p=emacs.git * xsmfns.c (smc_save_yourself_CB, x_session_initialize): Avoid strlen. (x_session_initialize): Do not assume string length fits in int. --- diff --git a/src/ChangeLog b/src/ChangeLog index 1aafb12e07c..f0752ff8e0c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2011-06-21 Paul Eggert + * xsmfns.c (smc_save_yourself_CB, x_session_initialize): Avoid strlen. + (x_session_initialize): Do not assume string length fits in int. + * xsettings.c (apply_xft_settings): Fix potential buffer overrun. This is unlikely, but can occur if DPI is outlandish. diff --git a/src/xsmfns.c b/src/xsmfns.c index c199036587f..cb56ae648d1 100644 --- a/src/xsmfns.c +++ b/src/xsmfns.c @@ -190,7 +190,7 @@ smc_save_yourself_CB (SmcConn smcConn, props[props_idx]->type = xstrdup (SmARRAY8); props[props_idx]->num_vals = 1; props[props_idx]->vals = &values[val_idx++]; - props[props_idx]->vals[0].length = strlen (SSDATA (Vinvocation_name)); + props[props_idx]->vals[0].length = SBYTES (Vinvocation_name); props[props_idx]->vals[0].value = SDATA (Vinvocation_name); ++props_idx; @@ -200,7 +200,7 @@ smc_save_yourself_CB (SmcConn smcConn, props[props_idx]->type = xstrdup (SmARRAY8); props[props_idx]->num_vals = 1; props[props_idx]->vals = &values[val_idx++]; - props[props_idx]->vals[0].length = strlen (SSDATA (Vuser_login_name)); + props[props_idx]->vals[0].length = SBYTES (Vuser_login_name); props[props_idx]->vals[0].value = SDATA (Vuser_login_name); ++props_idx; @@ -398,7 +398,7 @@ x_session_initialize (struct x_display_info *dpyinfo) char errorstring[SM_ERRORSTRING_LEN]; char* previous_id = NULL; SmcCallbacks callbacks; - int name_len = 0; + ptrdiff_t name_len = 0; ice_fd = -1; doing_interact = False; @@ -410,8 +410,8 @@ x_session_initialize (struct x_display_info *dpyinfo) /* Construct the path to the Emacs program. */ if (! EQ (Vinvocation_directory, Qnil)) - name_len += strlen (SSDATA (Vinvocation_directory)); - name_len += strlen (SSDATA (Vinvocation_name)); + name_len += SBYTES (Vinvocation_directory); + name_len += SBYTES (Vinvocation_name); /* This malloc will not be freed, but it is only done once, and hopefully not very large */ @@ -457,7 +457,7 @@ x_session_initialize (struct x_display_info *dpyinfo) if (smc_conn != 0) { - Vx_session_id = make_string (client_id, strlen (client_id)); + Vx_session_id = build_string (client_id); #ifdef USE_GTK /* GTK creats a leader window by itself, but we need to tell