mirror of
https://github.com/weechat/weechat.git
synced 2026-06-29 06:16:40 +02:00
Revert "core, plugins: replace "%lx" by "%p" in calls to sscanf"
This reverts commit e64ab3c675.
This was causing incorrect conversion of strings "0x..." to pointers on systems
like Solaris/illumos.
And as a side effect, buffers were sometimes empty in weechat relay clients
like glowing-bear.
This commit is contained in:
@@ -335,6 +335,7 @@ buflist_hsignal_cb (const void *pointer, void *data, const char *signal,
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
char *error, str_command[1024];
|
||||
long number, number2;
|
||||
unsigned long value;
|
||||
int rc, current_buffer_number;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -354,9 +355,10 @@ buflist_hsignal_cb (const void *pointer, void *data, const char *signal,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
rc = sscanf (ptr_pointer, "%p", &ptr_buffer);
|
||||
rc = sscanf (ptr_pointer, "%lx", &value);
|
||||
if ((rc == EOF) || (rc == 0))
|
||||
return WEECHAT_RC_OK;
|
||||
ptr_buffer = (struct t_gui_buffer *)value;
|
||||
|
||||
error = NULL;
|
||||
number = strtol (ptr_number, &error, 10);
|
||||
|
||||
@@ -43,6 +43,7 @@ fset_mouse_focus_cb (const void *pointer, void *data, struct t_hashtable *info)
|
||||
{
|
||||
const char *buffer;
|
||||
int rc, format_number;
|
||||
unsigned long value;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
long y, option_index;
|
||||
char *error, str_value[128];
|
||||
@@ -59,10 +60,12 @@ fset_mouse_focus_cb (const void *pointer, void *data, struct t_hashtable *info)
|
||||
if (!buffer)
|
||||
return info;
|
||||
|
||||
rc = sscanf (buffer, "%p", &ptr_buffer);
|
||||
rc = sscanf (buffer, "%lx", &value);
|
||||
if ((rc == EOF) || (rc == 0))
|
||||
return info;
|
||||
|
||||
ptr_buffer = (struct t_gui_buffer *)value;
|
||||
|
||||
if (!ptr_buffer || (ptr_buffer != fset_buffer))
|
||||
return info;
|
||||
|
||||
@@ -186,6 +189,7 @@ fset_mouse_hsignal_cb (const void *pointer, void *data, const char *signal,
|
||||
const char *ptr_key, *ptr_fset_option_pointer;
|
||||
char str_command[1024];
|
||||
struct t_fset_option *ptr_fset_option;
|
||||
unsigned long value;
|
||||
int rc, distance, num_options, min_y, max_y, i;
|
||||
int chat_line_x, chat_line_x2, y, y2, chat_line_y, chat_line_y2;
|
||||
int option_index, option_index2, index1, index2;
|
||||
@@ -204,9 +208,10 @@ fset_mouse_hsignal_cb (const void *pointer, void *data, const char *signal,
|
||||
if (!ptr_key || !ptr_fset_option_pointer)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
rc = sscanf (ptr_fset_option_pointer, "%p", &ptr_fset_option);
|
||||
rc = sscanf (ptr_fset_option_pointer, "%lx", &value);
|
||||
if ((rc == EOF) || (rc == 0))
|
||||
return WEECHAT_RC_OK;
|
||||
ptr_fset_option = (struct t_fset_option *)value;
|
||||
if (!ptr_fset_option)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
|
||||
@@ -626,6 +626,7 @@ struct t_hashtable *
|
||||
irc_bar_item_focus_buffer_nicklist (const void *pointer, void *data,
|
||||
struct t_hashtable *info)
|
||||
{
|
||||
unsigned long value;
|
||||
int rc;
|
||||
struct t_gui_buffer *buffer;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
@@ -636,10 +637,12 @@ irc_bar_item_focus_buffer_nicklist (const void *pointer, void *data,
|
||||
if (!str_buffer || !str_buffer[0])
|
||||
return NULL;
|
||||
|
||||
rc = sscanf (str_buffer, "%p", &buffer);
|
||||
rc = sscanf (str_buffer, "%lx", &value);
|
||||
if ((rc == EOF) || (rc == 0))
|
||||
return NULL;
|
||||
|
||||
buffer = (struct t_gui_buffer *)value;
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
/* make C compiler happy */
|
||||
|
||||
@@ -1313,6 +1313,7 @@ irc_list_mouse_hsignal_cb (const void *pointer, void *data, const char *signal,
|
||||
{
|
||||
const char *ptr_key, *ptr_chat_line_y, *ptr_buffer_pointer;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
unsigned long value;
|
||||
char str_command[1024];
|
||||
int rc;
|
||||
|
||||
@@ -1328,9 +1329,10 @@ irc_list_mouse_hsignal_cb (const void *pointer, void *data, const char *signal,
|
||||
if (!ptr_key || !ptr_buffer_pointer || !ptr_chat_line_y)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
rc = sscanf (ptr_buffer_pointer, "%p", &ptr_buffer);
|
||||
rc = sscanf (ptr_buffer_pointer, "%lx", &value);
|
||||
if ((rc == EOF) || (rc == 0))
|
||||
return WEECHAT_RC_OK;
|
||||
ptr_buffer = (struct t_gui_buffer *)value;
|
||||
if (!ptr_buffer)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ logger_info_log_file_cb (const void *pointer, void *data,
|
||||
const char *arguments)
|
||||
{
|
||||
int rc;
|
||||
unsigned long value;
|
||||
struct t_gui_buffer *buffer;
|
||||
struct t_logger_buffer *logger_buffer;
|
||||
|
||||
@@ -54,20 +55,16 @@ logger_info_log_file_cb (const void *pointer, void *data,
|
||||
buffer = NULL;
|
||||
if (strncmp (arguments, "0x", 2) == 0)
|
||||
{
|
||||
rc = sscanf (arguments, "%p", &buffer);
|
||||
if ((rc != EOF) && (rc != 0) && buffer)
|
||||
rc = sscanf (arguments, "%lx", &value);
|
||||
if ((rc != EOF) && (rc != 0) && value)
|
||||
{
|
||||
if (!weechat_hdata_check_pointer (weechat_hdata_get ("buffer"),
|
||||
NULL,
|
||||
buffer))
|
||||
if (weechat_hdata_check_pointer (weechat_hdata_get ("buffer"),
|
||||
NULL,
|
||||
(struct t_gui_buffer *)value))
|
||||
{
|
||||
buffer = NULL;
|
||||
buffer = (struct t_gui_buffer *)value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -407,7 +407,7 @@ plugin_script_str2ptr (struct t_weechat_plugin *weechat_plugin,
|
||||
const char *script_name, const char *function_name,
|
||||
const char *str_pointer)
|
||||
{
|
||||
void *pointer;
|
||||
unsigned long value;
|
||||
int rc;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
@@ -417,9 +417,9 @@ plugin_script_str2ptr (struct t_weechat_plugin *weechat_plugin,
|
||||
if ((str_pointer[0] != '0') || (str_pointer[1] != 'x'))
|
||||
goto invalid;
|
||||
|
||||
rc = sscanf (str_pointer, "%p", &pointer);
|
||||
rc = sscanf (str_pointer + 2, "%lx", &value);
|
||||
if ((rc != EOF) && (rc >= 1))
|
||||
return pointer;
|
||||
return (void *)value;
|
||||
|
||||
invalid:
|
||||
if ((weechat_plugin->debug >= 1) && script_name && function_name)
|
||||
|
||||
@@ -590,6 +590,7 @@ relay_weechat_msg_add_hdata (struct t_relay_weechat_msg *msg,
|
||||
char *path_returned;
|
||||
const char *hdata_name, *array_size;
|
||||
void *pointer, **path_pointers;
|
||||
unsigned long value;
|
||||
int rc, num_keys, num_path, i, type, pos_count, count, rc_sscanf;
|
||||
uint32_t count32;
|
||||
|
||||
@@ -630,9 +631,10 @@ relay_weechat_msg_add_hdata (struct t_relay_weechat_msg *msg,
|
||||
pos[0] = '\0';
|
||||
if (strncmp (list_path[0], "0x", 2) == 0)
|
||||
{
|
||||
rc_sscanf = sscanf (list_path[0], "%p", &pointer);
|
||||
rc_sscanf = sscanf (list_path[0], "%lx", &value);
|
||||
if ((rc_sscanf != EOF) && (rc_sscanf != 0))
|
||||
{
|
||||
pointer = (void *)value;
|
||||
if (!weechat_hdata_check_pointer (ptr_hdata_head, NULL, pointer))
|
||||
{
|
||||
if (weechat_relay_plugin->debug >= 1)
|
||||
@@ -646,10 +648,6 @@ relay_weechat_msg_add_hdata (struct t_relay_weechat_msg *msg,
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pointer = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
pointer = weechat_hdata_get_list (ptr_hdata_head, list_path[0]);
|
||||
|
||||
@@ -51,14 +51,17 @@ struct t_gui_buffer *
|
||||
relay_weechat_protocol_get_buffer (const char *arg)
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
unsigned long value;
|
||||
int rc;
|
||||
|
||||
ptr_buffer = NULL;
|
||||
|
||||
if (strncmp (arg, "0x", 2) == 0)
|
||||
{
|
||||
rc = sscanf (arg, "%p", &ptr_buffer);
|
||||
if ((rc != EOF) && (rc != 0) && ptr_buffer)
|
||||
rc = sscanf (arg, "%lx", &value);
|
||||
if ((rc != EOF) && (rc != 0))
|
||||
ptr_buffer = (struct t_gui_buffer *)value;
|
||||
if (ptr_buffer)
|
||||
{
|
||||
if (!weechat_hdata_check_pointer (
|
||||
relay_hdata_buffer,
|
||||
@@ -69,10 +72,6 @@ relay_weechat_protocol_get_buffer (const char *arg)
|
||||
ptr_buffer = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_buffer = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
ptr_buffer = weechat_buffer_search ("==", arg);
|
||||
@@ -529,7 +528,7 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(info)
|
||||
RELAY_WEECHAT_PROTOCOL_CALLBACK(infolist)
|
||||
{
|
||||
struct t_relay_weechat_msg *msg;
|
||||
void *pointer;
|
||||
unsigned long value;
|
||||
char *args;
|
||||
int rc;
|
||||
|
||||
@@ -538,17 +537,17 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(infolist)
|
||||
msg = relay_weechat_msg_new (id);
|
||||
if (msg)
|
||||
{
|
||||
pointer = NULL;
|
||||
value = 0;
|
||||
args = NULL;
|
||||
if (argc > 1)
|
||||
{
|
||||
rc = sscanf (argv[1], "%p", &pointer);
|
||||
rc = sscanf (argv[1], "%lx", &value);
|
||||
if ((rc == EOF) || (rc == 0))
|
||||
pointer = NULL;
|
||||
value = 0;
|
||||
if (argc > 2)
|
||||
args = argv_eol[2];
|
||||
}
|
||||
relay_weechat_msg_add_infolist (msg, argv[0], pointer, args);
|
||||
relay_weechat_msg_add_infolist (msg, argv[0], (void *)value, args);
|
||||
relay_weechat_msg_send (client, msg);
|
||||
relay_weechat_msg_free (msg);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ script_mouse_focus_chat_cb (const void *pointer, void *data,
|
||||
{
|
||||
const char *buffer;
|
||||
int rc;
|
||||
unsigned long value;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
long x;
|
||||
char *error, str_date[64];
|
||||
@@ -58,10 +59,12 @@ script_mouse_focus_chat_cb (const void *pointer, void *data,
|
||||
if (!buffer)
|
||||
return info;
|
||||
|
||||
rc = sscanf (buffer, "%p", &ptr_buffer);
|
||||
rc = sscanf (buffer, "%lx", &value);
|
||||
if ((rc == EOF) || (rc == 0))
|
||||
return info;
|
||||
|
||||
ptr_buffer = (struct t_gui_buffer *)value;
|
||||
|
||||
if (!ptr_buffer || (ptr_buffer != script_buffer))
|
||||
return info;
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ spell_info_info_spell_dict_cb (const void *pointer, void *data,
|
||||
const char *arguments)
|
||||
{
|
||||
int rc;
|
||||
unsigned long value;
|
||||
struct t_gui_buffer *buffer;
|
||||
const char *buffer_full_name, *ptr_dict;
|
||||
|
||||
@@ -55,9 +56,10 @@ spell_info_info_spell_dict_cb (const void *pointer, void *data,
|
||||
buffer_full_name = NULL;
|
||||
if (strncmp (arguments, "0x", 2) == 0)
|
||||
{
|
||||
rc = sscanf (arguments, "%p", &buffer);
|
||||
if ((rc != EOF) && (rc != 0) && buffer)
|
||||
rc = sscanf (arguments, "%lx", &value);
|
||||
if ((rc != EOF) && (rc != 0) && value)
|
||||
{
|
||||
buffer = (struct t_gui_buffer *)value;
|
||||
if (weechat_hdata_check_pointer (weechat_hdata_get ("buffer"),
|
||||
NULL, buffer))
|
||||
{
|
||||
|
||||
@@ -715,6 +715,7 @@ spell_modifier_cb (const void *pointer, void *data,
|
||||
const char *modifier,
|
||||
const char *modifier_data, const char *string)
|
||||
{
|
||||
unsigned long value;
|
||||
struct t_gui_buffer *buffer;
|
||||
struct t_spell_speller_buffer *ptr_speller_buffer;
|
||||
char **result, *ptr_string, *ptr_string_orig, *pos_space;
|
||||
@@ -737,10 +738,12 @@ spell_modifier_cb (const void *pointer, void *data,
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
||||
rc = sscanf (modifier_data, "%p", &buffer);
|
||||
rc = sscanf (modifier_data, "%lx", &value);
|
||||
if ((rc == EOF) || (rc == 0))
|
||||
return NULL;
|
||||
|
||||
buffer = (struct t_gui_buffer *)value;
|
||||
|
||||
/* check text during search only if option is enabled */
|
||||
if (weechat_buffer_get_integer (buffer, "text_search")
|
||||
&& !weechat_config_boolean (spell_config_check_during_search))
|
||||
|
||||
@@ -999,7 +999,7 @@ trigger_callback_line_cb (const void *pointer, void *data,
|
||||
{
|
||||
struct t_hashtable *hashtable;
|
||||
struct t_weelist_item *ptr_item;
|
||||
void *ptr;
|
||||
unsigned long value;
|
||||
const char *ptr_key, *ptr_value;
|
||||
char **tags, *str_tags, *string_no_color;
|
||||
int rc, num_tags;
|
||||
@@ -1023,10 +1023,10 @@ trigger_callback_line_cb (const void *pointer, void *data,
|
||||
ptr_value = weechat_hashtable_get (line, "buffer");
|
||||
if (!ptr_value || (ptr_value[0] != '0') || (ptr_value[1] != 'x'))
|
||||
goto end;
|
||||
rc = sscanf (ptr_value, "%p", &ptr);
|
||||
rc = sscanf (ptr_value + 2, "%lx", &value);
|
||||
if ((rc == EOF) || (rc < 1))
|
||||
goto end;
|
||||
ctx.buffer = ptr;
|
||||
ctx.buffer = (void *)value;
|
||||
|
||||
weechat_hashtable_set (ctx.pointers, "buffer", ctx.buffer);
|
||||
ptr_value = weechat_hashtable_get (line, "tags");
|
||||
@@ -1363,7 +1363,7 @@ trigger_callback_focus_cb (const void *pointer, void *data,
|
||||
struct t_hashtable *info)
|
||||
{
|
||||
const char *ptr_value;
|
||||
void *ptr;
|
||||
unsigned long value;
|
||||
int rc;
|
||||
|
||||
TRIGGER_CALLBACK_CB_INIT(info);
|
||||
@@ -1377,16 +1377,16 @@ trigger_callback_focus_cb (const void *pointer, void *data,
|
||||
ptr_value = weechat_hashtable_get (info, "_window");
|
||||
if (ptr_value && ptr_value[0] && (strncmp (ptr_value, "0x", 2) == 0))
|
||||
{
|
||||
rc = sscanf (ptr_value, "%p", &ptr);
|
||||
rc = sscanf (ptr_value + 2, "%lx", &value);
|
||||
if ((rc != EOF) && (rc >= 1))
|
||||
weechat_hashtable_set (ctx.pointers, "window", ptr);
|
||||
weechat_hashtable_set (ctx.pointers, "window", (void *)value);
|
||||
}
|
||||
ptr_value = weechat_hashtable_get (info, "_buffer");
|
||||
if (ptr_value && ptr_value[0] && (strncmp (ptr_value, "0x", 2) == 0))
|
||||
{
|
||||
rc = sscanf (ptr_value, "%p", &ptr);
|
||||
rc = sscanf (ptr_value + 2, "%lx", &value);
|
||||
if ((rc != EOF) && (rc >= 1))
|
||||
weechat_hashtable_set (ctx.pointers, "buffer", ptr);
|
||||
weechat_hashtable_set (ctx.pointers, "buffer", (void *)value);
|
||||
}
|
||||
|
||||
/* execute the trigger (conditions, regex, command) */
|
||||
|
||||
@@ -183,6 +183,7 @@ typing_input_text_for_buffer_modifier_cb (const void *pointer,
|
||||
const char *string)
|
||||
{
|
||||
int rc, text_search;
|
||||
unsigned long value;
|
||||
const char *ptr_input_for_buffer;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
struct t_typing_status *ptr_typing_status;
|
||||
@@ -193,9 +194,10 @@ typing_input_text_for_buffer_modifier_cb (const void *pointer,
|
||||
(void) modifier;
|
||||
(void) string;
|
||||
|
||||
rc = sscanf (modifier_data, "%p", &ptr_buffer);
|
||||
rc = sscanf (modifier_data, "%lx", &value);
|
||||
if ((rc == EOF) || (rc == 0))
|
||||
return NULL;
|
||||
ptr_buffer = (struct t_gui_buffer *)value;
|
||||
|
||||
/* ignore any change in input if the user is searching text in the buffer */
|
||||
text_search = weechat_buffer_get_integer (ptr_buffer, "text_search");
|
||||
@@ -382,6 +384,7 @@ typing_typing_set_nick_signal_cb (const void *pointer, void *data,
|
||||
{
|
||||
char **items;
|
||||
int num_items, rc, state, updated;
|
||||
unsigned long value;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
struct t_typing_status *ptr_typing_status;
|
||||
|
||||
@@ -396,9 +399,10 @@ typing_typing_set_nick_signal_cb (const void *pointer, void *data,
|
||||
if (!items || (num_items != 3))
|
||||
goto end;
|
||||
|
||||
rc = sscanf (items[0], "%p", &ptr_buffer);
|
||||
rc = sscanf (items[0], "%lx", &value);
|
||||
if ((rc == EOF) || (rc == 0))
|
||||
goto end;
|
||||
ptr_buffer = (struct t_gui_buffer *)value;
|
||||
if (!ptr_buffer)
|
||||
goto end;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user