idx
int64
func_before
string
Vulnerability Classification
string
vul
int64
func_after
string
patch
string
CWE ID
string
lines_before
string
lines_after
string
9,400
partition_create_device_added_cb (Daemon *daemon, const char *object_path, gpointer user_data) { CreatePartitionData *data = user_data; Device *device; /* check the device added is the partition we've created */ device = daemon_local_find_by_object_path (daemon, object_path); if (device != NULL && device->priv->device_is_partition && strcmp (device->priv->partition_slave, data->device->priv->object_path) == 0 && data->created_offset == device->priv->partition_offset && data->created_size == device->priv->partition_size) { /* yay! it is.. now create the file system if requested */ partition_create_found_device (device, data); g_signal_handler_disconnect (daemon, data->device_added_signal_handler_id); g_source_remove (data->device_added_timeout_id); partition_create_data_unref (data); } }
+Info
0
partition_create_device_added_cb (Daemon *daemon, const char *object_path, gpointer user_data) { CreatePartitionData *data = user_data; Device *device; /* check the device added is the partition we've created */ device = daemon_local_find_by_object_path (daemon, object_path); if (device != NULL && device->priv->device_is_partition && strcmp (device->priv->partition_slave, data->device->priv->object_path) == 0 && data->created_offset == device->priv->partition_offset && data->created_size == device->priv->partition_size) { /* yay! it is.. now create the file system if requested */ partition_create_found_device (device, data); g_signal_handler_disconnect (daemon, data->device_added_signal_handler_id); g_source_remove (data->device_added_timeout_id); partition_create_data_unref (data); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,401
partition_create_device_not_seen_cb (gpointer user_data) { CreatePartitionData *data = user_data; throw_error (data->context, ERROR_FAILED, "Error creating partition: timeout (10s) waiting for partition to show up"); g_signal_handler_disconnect (data->device->priv->daemon, data->device_added_signal_handler_id); partition_create_data_unref (data); return FALSE; }
+Info
0
partition_create_device_not_seen_cb (gpointer user_data) { CreatePartitionData *data = user_data; throw_error (data->context, ERROR_FAILED, "Error creating partition: timeout (10s) waiting for partition to show up"); g_signal_handler_disconnect (data->device->priv->daemon, data->device_added_signal_handler_id); partition_create_data_unref (data); return FALSE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,402
partition_create_filesystem_create_hook (DBusGMethodInvocation *context, Device *device, gboolean filesystem_create_succeeded, gpointer user_data) { if (!filesystem_create_succeeded) { /* dang.. FilesystemCreate already reported an error */ } else { /* it worked.. */ dbus_g_method_return (context, device->priv->object_path); } }
+Info
0
partition_create_filesystem_create_hook (DBusGMethodInvocation *context, Device *device, gboolean filesystem_create_succeeded, gpointer user_data) { if (!filesystem_create_succeeded) { /* dang.. FilesystemCreate already reported an error */ } else { /* it worked.. */ dbus_g_method_return (context, device->priv->object_path); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,403
partition_create_found_device (Device *device, CreatePartitionData *data) { if (strlen (data->fstype) > 0) { device_filesystem_create_internal (device, data->fstype, data->fsoptions, partition_create_filesystem_create_hook, NULL, data->context); } else { dbus_g_method_return (data->context, device->priv->object_path); } }
+Info
0
partition_create_found_device (Device *device, CreatePartitionData *data) { if (strlen (data->fstype) > 0) { device_filesystem_create_internal (device, data->fstype, data->fsoptions, partition_create_filesystem_create_hook, NULL, data->context); } else { dbus_g_method_return (data->context, device->priv->object_path); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,404
partition_modify_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { ModifyPartitionData *data = user_data; /* poke the kernel so we can reread the data */ device_generate_kernel_change_event (data->enclosing_device); device_generate_kernel_change_event (data->device); if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* update local copy, don't wait for the kernel */ device_set_partition_type (device, data->type); device_set_partition_label (device, data->label); device_set_partition_flags (device, data->flags); drain_pending_changes (device, FALSE); dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error modifying partition: helper exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
partition_modify_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { ModifyPartitionData *data = user_data; /* poke the kernel so we can reread the data */ device_generate_kernel_change_event (data->enclosing_device); device_generate_kernel_change_event (data->device); if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* update local copy, don't wait for the kernel */ device_set_partition_type (device, data->type); device_set_partition_label (device, data->label); device_set_partition_flags (device, data->flags); drain_pending_changes (device, FALSE); dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error modifying partition: helper exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,405
partition_modify_data_new (DBusGMethodInvocation *context, Device *device, Device *enclosing_device, const char *type, const char *label, char **flags) { ModifyPartitionData *data; data = g_new0 (ModifyPartitionData, 1); data->context = context; data->device = g_object_ref (device); data->enclosing_device = g_object_ref (enclosing_device); data->type = g_strdup (type); data->label = g_strdup (label); data->flags = g_strdupv (flags); return data; }
+Info
0
partition_modify_data_new (DBusGMethodInvocation *context, Device *device, Device *enclosing_device, const char *type, const char *label, char **flags) { ModifyPartitionData *data; data = g_new0 (ModifyPartitionData, 1); data->context = context; data->device = g_object_ref (device); data->enclosing_device = g_object_ref (enclosing_device); data->type = g_strdup (type); data->label = g_strdup (label); data->flags = g_strdupv (flags); return data; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,406
partition_modify_data_unref (ModifyPartitionData *data) { g_object_unref (data->device); g_object_unref (data->enclosing_device); g_free (data->type); g_free (data->label); g_free (data->flags); g_free (data); }
+Info
0
partition_modify_data_unref (ModifyPartitionData *data) { g_object_unref (data->device); g_object_unref (data->enclosing_device); g_free (data->type); g_free (data->label); g_free (data->flags); g_free (data); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,407
partition_table_create_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { CreatePartitionTableData *data = user_data; /* poke the kernel so we can reread the data */ device_generate_kernel_change_event (device); if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { if (g_strcmp0 (device->priv->partition_table_scheme, data->scheme) == 0) { dbus_g_method_return (context); } else { /* sit around and wait for the new partition table to appear */ data->device_changed_signal_handler_id = g_signal_connect_after (device->priv->daemon, "device-changed", (GCallback) partition_table_create_device_changed_cb, partition_table_create_data_ref (data)); /* set up timeout for error reporting if waiting failed * * (the signal handler and the timeout handler share the ref to data * as one will cancel the other) */ data->device_changed_timeout_id = g_timeout_add (10 * 1000, partition_table_create_device_not_changed_cb, data); } } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error creating partition table: helper exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
partition_table_create_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { CreatePartitionTableData *data = user_data; /* poke the kernel so we can reread the data */ device_generate_kernel_change_event (device); if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { if (g_strcmp0 (device->priv->partition_table_scheme, data->scheme) == 0) { dbus_g_method_return (context); } else { /* sit around and wait for the new partition table to appear */ data->device_changed_signal_handler_id = g_signal_connect_after (device->priv->daemon, "device-changed", (GCallback) partition_table_create_device_changed_cb, partition_table_create_data_ref (data)); /* set up timeout for error reporting if waiting failed * * (the signal handler and the timeout handler share the ref to data * as one will cancel the other) */ data->device_changed_timeout_id = g_timeout_add (10 * 1000, partition_table_create_device_not_changed_cb, data); } } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error creating partition table: helper exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,408
partition_table_create_data_new (DBusGMethodInvocation *context, Device *device, const char *scheme) { CreatePartitionTableData *data; data = g_new0 (CreatePartitionTableData, 1); data->refcount = 1; data->context = context; data->device = g_object_ref (device); data->scheme = g_strdup (scheme); return data; }
+Info
0
partition_table_create_data_new (DBusGMethodInvocation *context, Device *device, const char *scheme) { CreatePartitionTableData *data; data = g_new0 (CreatePartitionTableData, 1); data->refcount = 1; data->context = context; data->device = g_object_ref (device); data->scheme = g_strdup (scheme); return data; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,409
partition_table_create_data_ref (CreatePartitionTableData *data) { data->refcount++; return data; }
+Info
0
partition_table_create_data_ref (CreatePartitionTableData *data) { data->refcount++; return data; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,410
partition_table_create_device_changed_cb (Daemon *daemon, const char *object_path, gpointer user_data) { CreatePartitionTableData *data = user_data; Device *device; device = daemon_local_find_by_object_path (daemon, object_path); if (device == data->device) { if (g_strcmp0 (device->priv->partition_table_scheme, data->scheme) == 0 || (device->priv->partition_table_scheme == NULL && g_strcmp0 (data->scheme, "none") == 0)) { dbus_g_method_return (data->context); g_signal_handler_disconnect (daemon, data->device_changed_signal_handler_id); g_source_remove (data->device_changed_timeout_id); partition_table_create_data_unref (data); } } }
+Info
0
partition_table_create_device_changed_cb (Daemon *daemon, const char *object_path, gpointer user_data) { CreatePartitionTableData *data = user_data; Device *device; device = daemon_local_find_by_object_path (daemon, object_path); if (device == data->device) { if (g_strcmp0 (device->priv->partition_table_scheme, data->scheme) == 0 || (device->priv->partition_table_scheme == NULL && g_strcmp0 (data->scheme, "none") == 0)) { dbus_g_method_return (data->context); g_signal_handler_disconnect (daemon, data->device_changed_signal_handler_id); g_source_remove (data->device_changed_timeout_id); partition_table_create_data_unref (data); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,411
partition_table_create_device_not_changed_cb (gpointer user_data) { CreatePartitionTableData *data = user_data; throw_error (data->context, ERROR_FAILED, "Error creating partition table: timeout (10s) waiting for change"); g_signal_handler_disconnect (data->device->priv->daemon, data->device_changed_signal_handler_id); partition_table_create_data_unref (data); return FALSE; }
+Info
0
partition_table_create_device_not_changed_cb (gpointer user_data) { CreatePartitionTableData *data = user_data; throw_error (data->context, ERROR_FAILED, "Error creating partition table: timeout (10s) waiting for change"); g_signal_handler_disconnect (data->device->priv->daemon, data->device_changed_signal_handler_id); partition_table_create_data_unref (data); return FALSE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,412
poll_syncing_md_device (gpointer user_data) { Device *device = DEVICE (user_data); g_print ("**** POLL SYNCING MD %s\n", device->priv->native_path); device->priv->linux_md_poll_timeout_id = 0; daemon_local_synthesize_changed (device->priv->daemon, device); return FALSE; }
+Info
0
poll_syncing_md_device (gpointer user_data) { Device *device = DEVICE (user_data); g_print ("**** POLL SYNCING MD %s\n", device->priv->native_path); device->priv->linux_md_poll_timeout_id = 0; daemon_local_synthesize_changed (device->priv->daemon, device); return FALSE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,413
prepend_default_mount_options (const FSMountOptions *fsmo, uid_t caller_uid, char **given_options) { GPtrArray *options; int n; char *s; gid_t gid; options = g_ptr_array_new (); if (fsmo != NULL) { for (n = 0; fsmo->defaults != NULL && fsmo->defaults[n] != NULL; n++) { const char *option = fsmo->defaults[n]; if (strcmp (option, "uid=") == 0) { s = g_strdup_printf ("uid=%d", caller_uid); g_ptr_array_add (options, s); } else if (strcmp (option, "gid=") == 0) { gid = find_primary_gid (caller_uid); if (gid != (gid_t) - 1) { s = g_strdup_printf ("gid=%d", gid); g_ptr_array_add (options, s); } } else { g_ptr_array_add (options, g_strdup (option)); } } } for (n = 0; given_options[n] != NULL; n++) { g_ptr_array_add (options, g_strdup (given_options[n])); } g_ptr_array_add (options, NULL); return (char **) g_ptr_array_free (options, FALSE); }
+Info
0
prepend_default_mount_options (const FSMountOptions *fsmo, uid_t caller_uid, char **given_options) { GPtrArray *options; int n; char *s; gid_t gid; options = g_ptr_array_new (); if (fsmo != NULL) { for (n = 0; fsmo->defaults != NULL && fsmo->defaults[n] != NULL; n++) { const char *option = fsmo->defaults[n]; if (strcmp (option, "uid=") == 0) { s = g_strdup_printf ("uid=%d", caller_uid); g_ptr_array_add (options, s); } else if (strcmp (option, "gid=") == 0) { gid = find_primary_gid (caller_uid); if (gid != (gid_t) - 1) { s = g_strdup_printf ("gid=%d", gid); g_ptr_array_add (options, s); } } else { g_ptr_array_add (options, g_strdup (option)); } } } for (n = 0; given_options[n] != NULL; n++) { g_ptr_array_add (options, g_strdup (given_options[n])); } g_ptr_array_add (options, NULL); return (char **) g_ptr_array_free (options, FALSE); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,414
ptr_array_has_string (GPtrArray *p, const gchar *str) { guint n; gboolean ret; ret = FALSE; for (n = 0; n < p->len; n++) { if (g_strcmp0 (p->pdata[n], str) == 0) { ret = TRUE; goto out; } } out: return ret; }
+Info
0
ptr_array_has_string (GPtrArray *p, const gchar *str) { guint n; gboolean ret; ret = FALSE; for (n = 0; n < p->len; n++) { if (g_strcmp0 (p->pdata[n], str) == 0) { ret = TRUE; goto out; } } out: return ret; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,415
ptr_str_array_compare (const gchar **a, const gchar **b) { return g_strcmp0 (*a, *b); }
+Info
0
ptr_str_array_compare (const gchar **a, const gchar **b) { return g_strcmp0 (*a, *b); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,416
register_disks_device (Device *device) { DBusConnection *connection; GError *error = NULL; device->priv->system_bus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); if (device->priv->system_bus_connection == NULL) { if (error != NULL) { g_critical ("error getting system bus: %s", error->message); g_error_free (error); } goto error; } connection = dbus_g_connection_get_connection (device->priv->system_bus_connection); device->priv->object_path = compute_object_path (device->priv->native_path); /* safety first */ if (dbus_g_connection_lookup_g_object (device->priv->system_bus_connection, device->priv->object_path) != NULL) { g_error ("**** HACK: Wanting to register object at path `%s' but there is already an " "object there. This is an internal error in the daemon. Aborting.\n", device->priv->object_path); } dbus_g_connection_register_g_object (device->priv->system_bus_connection, device->priv->object_path, G_OBJECT (device)); return TRUE; error: return FALSE; }
+Info
0
register_disks_device (Device *device) { DBusConnection *connection; GError *error = NULL; device->priv->system_bus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); if (device->priv->system_bus_connection == NULL) { if (error != NULL) { g_critical ("error getting system bus: %s", error->message); g_error_free (error); } goto error; } connection = dbus_g_connection_get_connection (device->priv->system_bus_connection); device->priv->object_path = compute_object_path (device->priv->native_path); /* safety first */ if (dbus_g_connection_lookup_g_object (device->priv->system_bus_connection, device->priv->object_path) != NULL) { g_error ("**** HACK: Wanting to register object at path `%s' but there is already an " "object there. This is an internal error in the daemon. Aborting.\n", device->priv->object_path); } dbus_g_connection_register_g_object (device->priv->system_bus_connection, device->priv->object_path, G_OBJECT (device)); return TRUE; error: return FALSE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,417
remove_component_data_new (DBusGMethodInvocation *context, Device *slave, char **options) { RemoveComponentData *data; data = g_new0 (RemoveComponentData, 1); data->refcount = 1; data->context = context; data->slave = g_object_ref (slave); data->options = g_strdupv (options); return data; }
+Info
0
remove_component_data_new (DBusGMethodInvocation *context, Device *slave, char **options) { RemoveComponentData *data; data = g_new0 (RemoveComponentData, 1); data->refcount = 1; data->context = context; data->slave = g_object_ref (slave); data->options = g_strdupv (options); return data; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,418
remove_component_data_ref (RemoveComponentData *data) { data->refcount++; return data; }
+Info
0
remove_component_data_ref (RemoveComponentData *data) { data->refcount++; return data; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,419
remove_component_data_unref (RemoveComponentData *data) { data->refcount--; if (data->refcount == 0) { g_object_unref (data->slave); g_free (data->options); g_free (data); } }
+Info
0
remove_component_data_unref (RemoveComponentData *data) { data->refcount--; if (data->refcount == 0) { g_object_unref (data->slave); g_free (data->options); g_free (data); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,420
spindown_inhibitor_disconnected_cb (Inhibitor *inhibitor, Device *device) { device->priv->spindown_inhibitors = g_list_remove (device->priv->spindown_inhibitors, inhibitor); g_signal_handlers_disconnect_by_func (inhibitor, spindown_inhibitor_disconnected_cb, device); g_object_unref (inhibitor); update_info (device); drain_pending_changes (device, FALSE); daemon_local_update_spindown (device->priv->daemon); }
+Info
0
spindown_inhibitor_disconnected_cb (Inhibitor *inhibitor, Device *device) { device->priv->spindown_inhibitors = g_list_remove (device->priv->spindown_inhibitors, inhibitor); g_signal_handlers_disconnect_by_func (inhibitor, spindown_inhibitor_disconnected_cb, device); g_object_unref (inhibitor); update_info (device); drain_pending_changes (device, FALSE); daemon_local_update_spindown (device->priv->daemon); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,421
sysfs_file_exists (const char *dir, const char *attribute) { gboolean result; char *filename; result = FALSE; filename = g_build_filename (dir, attribute, NULL); if (g_file_test (filename, G_FILE_TEST_EXISTS)) { result = TRUE; } g_free (filename); return result; }
+Info
0
sysfs_file_exists (const char *dir, const char *attribute) { gboolean result; char *filename; result = FALSE; filename = g_build_filename (dir, attribute, NULL); if (g_file_test (filename, G_FILE_TEST_EXISTS)) { result = TRUE; } g_free (filename); return result; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,422
sysfs_get_double (const char *dir, const char *attribute) { double result; char *contents; char *filename; result = 0.0; filename = g_build_filename (dir, attribute, NULL); if (g_file_get_contents (filename, &contents, NULL, NULL)) { result = atof (contents); g_free (contents); } g_free (filename); return result; }
+Info
0
sysfs_get_double (const char *dir, const char *attribute) { double result; char *contents; char *filename; result = 0.0; filename = g_build_filename (dir, attribute, NULL); if (g_file_get_contents (filename, &contents, NULL, NULL)) { result = atof (contents); g_free (contents); } g_free (filename); return result; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,423
sysfs_get_int (const char *dir, const char *attribute) { int result; char *contents; char *filename; result = 0; filename = g_build_filename (dir, attribute, NULL); if (g_file_get_contents (filename, &contents, NULL, NULL)) { result = strtol (contents, NULL, 0); g_free (contents); } g_free (filename); return result; }
+Info
0
sysfs_get_int (const char *dir, const char *attribute) { int result; char *contents; char *filename; result = 0; filename = g_build_filename (dir, attribute, NULL); if (g_file_get_contents (filename, &contents, NULL, NULL)) { result = strtol (contents, NULL, 0); g_free (contents); } g_free (filename); return result; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,424
sysfs_get_string (const char *dir, const char *attribute) { char *result; char *filename; result = NULL; filename = g_build_filename (dir, attribute, NULL); if (!g_file_get_contents (filename, &result, NULL, NULL)) { result = g_strdup (""); } g_free (filename); return result; }
+Info
0
sysfs_get_string (const char *dir, const char *attribute) { char *result; char *filename; result = NULL; filename = g_build_filename (dir, attribute, NULL); if (!g_file_get_contents (filename, &result, NULL, NULL)) { result = g_strdup (""); } g_free (filename); return result; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,425
sysfs_get_uint64 (const char *dir, const char *attribute) { guint64 result; char *contents; char *filename; result = 0; filename = g_build_filename (dir, attribute, NULL); if (g_file_get_contents (filename, &contents, NULL, NULL)) { result = strtoll (contents, NULL, 0); g_free (contents); } g_free (filename); return result; }
+Info
0
sysfs_get_uint64 (const char *dir, const char *attribute) { guint64 result; char *contents; char *filename; result = 0; filename = g_build_filename (dir, attribute, NULL); if (g_file_get_contents (filename, &contents, NULL, NULL)) { result = strtoll (contents, NULL, 0); g_free (contents); } g_free (filename); return result; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,426
sysfs_resolve_link (const char *sysfs_path, const char *name) { char *full_path; char link_path[PATH_MAX]; char resolved_path[PATH_MAX]; ssize_t num; gboolean found_it; found_it = FALSE; full_path = g_build_filename (sysfs_path, name, NULL); num = readlink (full_path, link_path, sizeof(link_path) - 1); if (num != -1) { char *absolute_path; link_path[num] = '\0'; absolute_path = g_build_filename (sysfs_path, link_path, NULL); if (realpath (absolute_path, resolved_path) != NULL) { found_it = TRUE; } g_free (absolute_path); } g_free (full_path); if (found_it) return g_strdup (resolved_path); else return NULL; }
+Info
0
sysfs_resolve_link (const char *sysfs_path, const char *name) { char *full_path; char link_path[PATH_MAX]; char resolved_path[PATH_MAX]; ssize_t num; gboolean found_it; found_it = FALSE; full_path = g_build_filename (sysfs_path, name, NULL); num = readlink (full_path, link_path, sizeof(link_path) - 1); if (num != -1) { char *absolute_path; link_path[num] = '\0'; absolute_path = g_build_filename (sysfs_path, link_path, NULL); if (realpath (absolute_path, resolved_path) != NULL) { found_it = TRUE; } g_free (absolute_path); } g_free (full_path); if (found_it) return g_strdup (resolved_path); else return NULL; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,427
throw_error (DBusGMethodInvocation *context, int error_code, const char *format, ...) { GError *error; va_list args; char *message; if (context == NULL) return TRUE; va_start (args, format); message = g_strdup_vprintf (format, args); va_end (args); error = g_error_new (ERROR, error_code, "%s", message); dbus_g_method_return_error (context, error); g_error_free (error); g_free (message); return TRUE; }
+Info
0
throw_error (DBusGMethodInvocation *context, int error_code, const char *format, ...) { GError *error; va_list args; char *message; if (context == NULL) return TRUE; va_start (args, format); message = g_strdup_vprintf (format, args); va_end (args); error = g_error_new (ERROR, error_code, "%s", message); dbus_g_method_return_error (context, error); g_error_free (error); g_free (message); return TRUE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,428
unlock_encryption_data_new (DBusGMethodInvocation *context, Device *device, UnlockEncryptionHookFunc hook_func, gpointer hook_user_data) { UnlockEncryptionData *data; data = g_new0 (UnlockEncryptionData, 1); data->refcount = 1; data->context = context; data->device = g_object_ref (device); data->hook_func = hook_func; data->hook_user_data = hook_user_data; return data; }
+Info
0
unlock_encryption_data_new (DBusGMethodInvocation *context, Device *device, UnlockEncryptionHookFunc hook_func, gpointer hook_user_data) { UnlockEncryptionData *data; data = g_new0 (UnlockEncryptionData, 1); data->refcount = 1; data->context = context; data->device = g_object_ref (device); data->hook_func = hook_func; data->hook_user_data = hook_user_data; return data; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,429
unlock_encryption_data_ref (UnlockEncryptionData *data) { data->refcount++; return data; }
+Info
0
unlock_encryption_data_ref (UnlockEncryptionData *data) { data->refcount++; return data; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,430
unlock_encryption_data_unref (UnlockEncryptionData *data) { data->refcount--; if (data->refcount == 0) { g_object_unref (data->device); g_free (data); } }
+Info
0
unlock_encryption_data_unref (UnlockEncryptionData *data) { data->refcount--; if (data->refcount == 0) { g_object_unref (data->device); g_free (data); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,431
update_info (Device *device) { char *s; guint n; gboolean ret; char *path; GDir *dir; const char *name; GList *l; GList *old_slaves_objpath; GList *old_holders_objpath; GList *cur_slaves_objpath; GList *cur_holders_objpath; GList *added_objpath; GList *removed_objpath; GPtrArray *symlinks_by_id; GPtrArray *symlinks_by_path; GPtrArray *slaves; GPtrArray *holders; gint major; gint minor; gboolean media_available; ret = FALSE; PROFILE ("update_info(device=%s) start", device->priv->native_path); g_print ("**** UPDATING %s\n", device->priv->native_path); /* need the slaves/holders to synthesize 'change' events if a device goes away (since the kernel * doesn't do generate these) */ old_slaves_objpath = dup_list_from_ptrarray (device->priv->slaves_objpath); old_holders_objpath = dup_list_from_ptrarray (device->priv->holders_objpath); /* drive identification */ if (sysfs_file_exists (device->priv->native_path, "range")) { device_set_device_is_drive (device, TRUE); } else { device_set_device_is_drive (device, FALSE); } if (!g_udev_device_has_property (device->priv->d, "MAJOR") || !g_udev_device_has_property (device->priv->d, "MINOR")) { g_warning ("No major/minor for %s", device->priv->native_path); goto out; } /* ignore dm devices that are suspended */ if (g_str_has_prefix (g_udev_device_get_name (device->priv->d), "dm-")) { if (g_strcmp0 (g_udev_device_get_property (device->priv->d, "DM_SUSPENDED"), "1") == 0) goto out; } major = g_udev_device_get_property_as_int (device->priv->d, "MAJOR"); minor = g_udev_device_get_property_as_int (device->priv->d, "MINOR"); device->priv->dev = makedev (major, minor); device_set_device_file (device, g_udev_device_get_device_file (device->priv->d)); if (device->priv->device_file == NULL) { g_warning ("No device file for %s", device->priv->native_path); goto out; } const char * const * symlinks; symlinks = g_udev_device_get_device_file_symlinks (device->priv->d); symlinks_by_id = g_ptr_array_new (); symlinks_by_path = g_ptr_array_new (); for (n = 0; symlinks[n] != NULL; n++) { if (g_str_has_prefix (symlinks[n], "/dev/disk/by-id/") || g_str_has_prefix (symlinks[n], "/dev/disk/by-uuid/")) { g_ptr_array_add (symlinks_by_id, (gpointer) symlinks[n]); } else if (g_str_has_prefix (symlinks[n], "/dev/disk/by-path/")) { g_ptr_array_add (symlinks_by_path, (gpointer) symlinks[n]); } } g_ptr_array_sort (symlinks_by_id, (GCompareFunc) ptr_str_array_compare); g_ptr_array_sort (symlinks_by_path, (GCompareFunc) ptr_str_array_compare); g_ptr_array_add (symlinks_by_id, NULL); g_ptr_array_add (symlinks_by_path, NULL); device_set_device_file_by_id (device, (GStrv) symlinks_by_id->pdata); device_set_device_file_by_path (device, (GStrv) symlinks_by_path->pdata); g_ptr_array_free (symlinks_by_id, TRUE); g_ptr_array_free (symlinks_by_path, TRUE); device_set_device_is_removable (device, (sysfs_get_int (device->priv->native_path, "removable") != 0)); /* device_is_media_available and device_media_detection_time property */ if (device->priv->device_is_removable) { media_available = FALSE; if (!g_udev_device_get_property_as_boolean (device->priv->d, "ID_CDROM")) { int fd; fd = open (device->priv->device_file, O_RDONLY); if (fd >= 0) { media_available = TRUE; close (fd); } } else { if (g_udev_device_get_property_as_boolean (device->priv->d, "ID_CDROM_MEDIA")) { media_available = TRUE; } else { media_available = FALSE; } } } else { media_available = TRUE; } device_set_device_is_media_available (device, media_available); if (media_available) { if (device->priv->device_media_detection_time == 0) device_set_device_media_detection_time (device, (guint64) time (NULL)); } else { device_set_device_media_detection_time (device, 0); } /* device_size, device_block_size and device_is_read_only properties */ if (device->priv->device_is_media_available) { guint64 block_size; device_set_device_size (device, sysfs_get_uint64 (device->priv->native_path, "size") * ((guint64) 512)); device_set_device_is_read_only (device, (sysfs_get_int (device->priv->native_path, "ro") != 0)); /* This is not available on all devices so fall back to 512 if unavailable. * * Another way to get this information is the BLKSSZGET ioctl but we don't want * to open the device. Ideally vol_id would export it. */ block_size = sysfs_get_uint64 (device->priv->native_path, "queue/hw_sector_size"); if (block_size == 0) block_size = 512; device_set_device_block_size (device, block_size); } else { device_set_device_size (device, 0); device_set_device_block_size (device, 0); device_set_device_is_read_only (device, FALSE); } /* Maintain (non-exported) properties holders and slaves for the holders resp. slaves * directories in sysfs. The entries in these arrays are object paths - we ignore * an entry unless it corresponds to an device in our local database. */ path = g_build_filename (device->priv->native_path, "slaves", NULL); slaves = g_ptr_array_new (); if ((dir = g_dir_open (path, 0, NULL)) != NULL) { while ((name = g_dir_read_name (dir)) != NULL) { Device *device2; s = compute_object_path (name); device2 = daemon_local_find_by_object_path (device->priv->daemon, s); if (device2 != NULL) { g_ptr_array_add (slaves, s); } else { g_free (s); } } g_dir_close (dir); } g_free (path); g_ptr_array_sort (slaves, (GCompareFunc) ptr_str_array_compare); g_ptr_array_add (slaves, NULL); device_set_slaves_objpath (device, (GStrv) slaves->pdata); g_ptr_array_foreach (slaves, (GFunc) g_free, NULL); g_ptr_array_free (slaves, TRUE); path = g_build_filename (device->priv->native_path, "holders", NULL); holders = g_ptr_array_new (); if ((dir = g_dir_open (path, 0, NULL)) != NULL) { while ((name = g_dir_read_name (dir)) != NULL) { Device *device2; s = compute_object_path (name); device2 = daemon_local_find_by_object_path (device->priv->daemon, s); if (device2 != NULL) { g_ptr_array_add (holders, s); } else { g_free (s); } } g_dir_close (dir); } g_free (path); g_ptr_array_sort (holders, (GCompareFunc) ptr_str_array_compare); g_ptr_array_add (holders, NULL); device_set_holders_objpath (device, (GStrv) holders->pdata); g_ptr_array_foreach (holders, (GFunc) g_free, NULL); g_ptr_array_free (holders, TRUE); /* ------------------------------------- */ /* Now set all properties from udev data */ /* ------------------------------------- */ /* at this point we have * * - device_file * - device_file_by_id * - device_file_by_path * - device_size * - device_block_size * - device_is_removable * - device_is_read_only * - device_is_drive * - device_is_media_available * - device_is_partition * - device_is_partition_table * - slaves_objpath * - holders_objpath * * - partition_number * - partition_slave * */ /* device_is_linux_loop and linux_loop_* properties */ if (!update_info_linux_loop (device)) goto out; /* partition_* properties */ if (!update_info_partition (device)) goto out; /* partition_table_* properties */ if (!update_info_partition_table (device)) goto out; /* device_presentation_hide, device_presentation_name and device_presentation_icon_name properties */ if (!update_info_presentation (device)) goto out; /* id_* properties */ if (!update_info_id (device)) goto out; /* drive_* properties */ if (!update_info_drive (device)) goto out; /* device_is_optical_disc and optical_disc_* properties */ if (!update_info_optical_disc (device)) goto out; /* device_is_luks and luks_holder */ if (!update_info_luks (device)) goto out; /* device_is_luks_cleartext and luks_cleartext_* properties */ if (!update_info_luks_cleartext (device)) goto out; #ifdef HAVE_LVM2 /* device_is_linux_lvm2_lv and linux_lvm2_lv_* properties */ if (!update_info_linux_lvm2_lv (device)) goto out; /* device_is_linux_lvm2_pv and linux_lvm2_pv_* properties */ if (!update_info_linux_lvm2_pv (device)) goto out; #endif #ifdef HAVE_DMMP /* device_is_linux_dmmp and linux_dmmp_* properties */ if (!update_info_linux_dmmp (device)) goto out; /* device_is_partition and partition_* properties for dm-0 "partitions" on a multi-path device */ if (!update_info_partition_on_linux_dmmp (device)) goto out; /* device_is_linux_dmmp_component and linux_dmmp_component_* properties */ if (!update_info_linux_dmmp_component (device)) goto out; #endif /* device_is_linux_md_component and linux_md_component_* properties */ if (!update_info_linux_md_component (device)) goto out; /* device_is_linux_md and linux_md_* properties */ if (!update_info_linux_md (device)) goto out; /* drive_ata_smart_* properties */ if (!update_info_drive_ata_smart (device)) goto out; /* drive_can_spindown property */ if (!update_info_drive_can_spindown (device)) goto out; /* device_is_system_internal property */ if (!update_info_is_system_internal (device)) goto out; /* device_is_mounted, device_mount, device_mounted_by_uid */ if (!update_info_mount_state (device)) goto out; /* device_is_media_change_detected, device_is_media_change_detection_* properties */ if (!update_info_media_detection (device)) goto out; /* drive_adapter proprety */ if (!update_info_drive_adapter (device)) goto out; /* drive_ports property */ if (!update_info_drive_ports (device)) goto out; /* drive_similar_devices property */ if (!update_info_drive_similar_devices (device)) goto out; ret = TRUE; out: /* Now check if holders/ or slaves/ has changed since last update. We compute * the delta and do update_info() on each holder/slave that has been * added/removed. * * Note that this won't trigger an endless loop since we look at the diffs. * * We have to do this because the kernel doesn't generate any 'change' event * when slaves/ or holders/ change. This is unfortunate because we *need* such * a change event to update properties devices (for example: luks_holder). * * We do the update in idle because the update may depend on the device * currently being processed being added. */ cur_slaves_objpath = dup_list_from_ptrarray (device->priv->slaves_objpath); cur_holders_objpath = dup_list_from_ptrarray (device->priv->holders_objpath); old_slaves_objpath = g_list_sort (old_slaves_objpath, (GCompareFunc) g_strcmp0); old_holders_objpath = g_list_sort (old_holders_objpath, (GCompareFunc) g_strcmp0); cur_slaves_objpath = g_list_sort (cur_slaves_objpath, (GCompareFunc) g_strcmp0); cur_holders_objpath = g_list_sort (cur_holders_objpath, (GCompareFunc) g_strcmp0); diff_sorted_lists (old_slaves_objpath, cur_slaves_objpath, (GCompareFunc) g_strcmp0, &added_objpath, &removed_objpath); for (l = added_objpath; l != NULL; l = l->next) { const gchar *objpath2 = l->data; Device *device2; device2 = daemon_local_find_by_object_path (device->priv->daemon, objpath2); if (device2 != NULL) { update_info_in_idle (device2); } else { g_print ("**** NOTE: %s added non-existant slave %s\n", device->priv->object_path, objpath2); } } for (l = removed_objpath; l != NULL; l = l->next) { const gchar *objpath2 = l->data; Device *device2; device2 = daemon_local_find_by_object_path (device->priv->daemon, objpath2); if (device2 != NULL) { update_info_in_idle (device2); } else { } } g_list_free (added_objpath); g_list_free (removed_objpath); diff_sorted_lists (old_holders_objpath, cur_holders_objpath, (GCompareFunc) g_strcmp0, &added_objpath, &removed_objpath); for (l = added_objpath; l != NULL; l = l->next) { const gchar *objpath2 = l->data; Device *device2; device2 = daemon_local_find_by_object_path (device->priv->daemon, objpath2); if (device2 != NULL) { update_info_in_idle (device2); } else { g_print ("**** NOTE: %s added non-existant holder %s\n", device->priv->object_path, objpath2); } } for (l = removed_objpath; l != NULL; l = l->next) { const gchar *objpath2 = l->data; Device *device2; device2 = daemon_local_find_by_object_path (device->priv->daemon, objpath2); if (device2 != NULL) { update_info_in_idle (device2); } else { } } g_list_free (added_objpath); g_list_free (removed_objpath); g_list_foreach (old_slaves_objpath, (GFunc) g_free, NULL); g_list_free (old_slaves_objpath); g_list_foreach (old_holders_objpath, (GFunc) g_free, NULL); g_list_free (old_holders_objpath); g_list_foreach (cur_slaves_objpath, (GFunc) g_free, NULL); g_list_free (cur_slaves_objpath); g_list_foreach (cur_holders_objpath, (GFunc) g_free, NULL); g_list_free (cur_holders_objpath); PROFILE ("update_info(device=%s) end", device->priv->native_path); return ret; }
+Info
0
update_info (Device *device) { char *s; guint n; gboolean ret; char *path; GDir *dir; const char *name; GList *l; GList *old_slaves_objpath; GList *old_holders_objpath; GList *cur_slaves_objpath; GList *cur_holders_objpath; GList *added_objpath; GList *removed_objpath; GPtrArray *symlinks_by_id; GPtrArray *symlinks_by_path; GPtrArray *slaves; GPtrArray *holders; gint major; gint minor; gboolean media_available; ret = FALSE; PROFILE ("update_info(device=%s) start", device->priv->native_path); g_print ("**** UPDATING %s\n", device->priv->native_path); /* need the slaves/holders to synthesize 'change' events if a device goes away (since the kernel * doesn't do generate these) */ old_slaves_objpath = dup_list_from_ptrarray (device->priv->slaves_objpath); old_holders_objpath = dup_list_from_ptrarray (device->priv->holders_objpath); /* drive identification */ if (sysfs_file_exists (device->priv->native_path, "range")) { device_set_device_is_drive (device, TRUE); } else { device_set_device_is_drive (device, FALSE); } if (!g_udev_device_has_property (device->priv->d, "MAJOR") || !g_udev_device_has_property (device->priv->d, "MINOR")) { g_warning ("No major/minor for %s", device->priv->native_path); goto out; } /* ignore dm devices that are suspended */ if (g_str_has_prefix (g_udev_device_get_name (device->priv->d), "dm-")) { if (g_strcmp0 (g_udev_device_get_property (device->priv->d, "DM_SUSPENDED"), "1") == 0) goto out; } major = g_udev_device_get_property_as_int (device->priv->d, "MAJOR"); minor = g_udev_device_get_property_as_int (device->priv->d, "MINOR"); device->priv->dev = makedev (major, minor); device_set_device_file (device, g_udev_device_get_device_file (device->priv->d)); if (device->priv->device_file == NULL) { g_warning ("No device file for %s", device->priv->native_path); goto out; } const char * const * symlinks; symlinks = g_udev_device_get_device_file_symlinks (device->priv->d); symlinks_by_id = g_ptr_array_new (); symlinks_by_path = g_ptr_array_new (); for (n = 0; symlinks[n] != NULL; n++) { if (g_str_has_prefix (symlinks[n], "/dev/disk/by-id/") || g_str_has_prefix (symlinks[n], "/dev/disk/by-uuid/")) { g_ptr_array_add (symlinks_by_id, (gpointer) symlinks[n]); } else if (g_str_has_prefix (symlinks[n], "/dev/disk/by-path/")) { g_ptr_array_add (symlinks_by_path, (gpointer) symlinks[n]); } } g_ptr_array_sort (symlinks_by_id, (GCompareFunc) ptr_str_array_compare); g_ptr_array_sort (symlinks_by_path, (GCompareFunc) ptr_str_array_compare); g_ptr_array_add (symlinks_by_id, NULL); g_ptr_array_add (symlinks_by_path, NULL); device_set_device_file_by_id (device, (GStrv) symlinks_by_id->pdata); device_set_device_file_by_path (device, (GStrv) symlinks_by_path->pdata); g_ptr_array_free (symlinks_by_id, TRUE); g_ptr_array_free (symlinks_by_path, TRUE); device_set_device_is_removable (device, (sysfs_get_int (device->priv->native_path, "removable") != 0)); /* device_is_media_available and device_media_detection_time property */ if (device->priv->device_is_removable) { media_available = FALSE; if (!g_udev_device_get_property_as_boolean (device->priv->d, "ID_CDROM")) { int fd; fd = open (device->priv->device_file, O_RDONLY); if (fd >= 0) { media_available = TRUE; close (fd); } } else { if (g_udev_device_get_property_as_boolean (device->priv->d, "ID_CDROM_MEDIA")) { media_available = TRUE; } else { media_available = FALSE; } } } else { media_available = TRUE; } device_set_device_is_media_available (device, media_available); if (media_available) { if (device->priv->device_media_detection_time == 0) device_set_device_media_detection_time (device, (guint64) time (NULL)); } else { device_set_device_media_detection_time (device, 0); } /* device_size, device_block_size and device_is_read_only properties */ if (device->priv->device_is_media_available) { guint64 block_size; device_set_device_size (device, sysfs_get_uint64 (device->priv->native_path, "size") * ((guint64) 512)); device_set_device_is_read_only (device, (sysfs_get_int (device->priv->native_path, "ro") != 0)); /* This is not available on all devices so fall back to 512 if unavailable. * * Another way to get this information is the BLKSSZGET ioctl but we don't want * to open the device. Ideally vol_id would export it. */ block_size = sysfs_get_uint64 (device->priv->native_path, "queue/hw_sector_size"); if (block_size == 0) block_size = 512; device_set_device_block_size (device, block_size); } else { device_set_device_size (device, 0); device_set_device_block_size (device, 0); device_set_device_is_read_only (device, FALSE); } /* Maintain (non-exported) properties holders and slaves for the holders resp. slaves * directories in sysfs. The entries in these arrays are object paths - we ignore * an entry unless it corresponds to an device in our local database. */ path = g_build_filename (device->priv->native_path, "slaves", NULL); slaves = g_ptr_array_new (); if ((dir = g_dir_open (path, 0, NULL)) != NULL) { while ((name = g_dir_read_name (dir)) != NULL) { Device *device2; s = compute_object_path (name); device2 = daemon_local_find_by_object_path (device->priv->daemon, s); if (device2 != NULL) { g_ptr_array_add (slaves, s); } else { g_free (s); } } g_dir_close (dir); } g_free (path); g_ptr_array_sort (slaves, (GCompareFunc) ptr_str_array_compare); g_ptr_array_add (slaves, NULL); device_set_slaves_objpath (device, (GStrv) slaves->pdata); g_ptr_array_foreach (slaves, (GFunc) g_free, NULL); g_ptr_array_free (slaves, TRUE); path = g_build_filename (device->priv->native_path, "holders", NULL); holders = g_ptr_array_new (); if ((dir = g_dir_open (path, 0, NULL)) != NULL) { while ((name = g_dir_read_name (dir)) != NULL) { Device *device2; s = compute_object_path (name); device2 = daemon_local_find_by_object_path (device->priv->daemon, s); if (device2 != NULL) { g_ptr_array_add (holders, s); } else { g_free (s); } } g_dir_close (dir); } g_free (path); g_ptr_array_sort (holders, (GCompareFunc) ptr_str_array_compare); g_ptr_array_add (holders, NULL); device_set_holders_objpath (device, (GStrv) holders->pdata); g_ptr_array_foreach (holders, (GFunc) g_free, NULL); g_ptr_array_free (holders, TRUE); /* ------------------------------------- */ /* Now set all properties from udev data */ /* ------------------------------------- */ /* at this point we have * * - device_file * - device_file_by_id * - device_file_by_path * - device_size * - device_block_size * - device_is_removable * - device_is_read_only * - device_is_drive * - device_is_media_available * - device_is_partition * - device_is_partition_table * - slaves_objpath * - holders_objpath * * - partition_number * - partition_slave * */ /* device_is_linux_loop and linux_loop_* properties */ if (!update_info_linux_loop (device)) goto out; /* partition_* properties */ if (!update_info_partition (device)) goto out; /* partition_table_* properties */ if (!update_info_partition_table (device)) goto out; /* device_presentation_hide, device_presentation_name and device_presentation_icon_name properties */ if (!update_info_presentation (device)) goto out; /* id_* properties */ if (!update_info_id (device)) goto out; /* drive_* properties */ if (!update_info_drive (device)) goto out; /* device_is_optical_disc and optical_disc_* properties */ if (!update_info_optical_disc (device)) goto out; /* device_is_luks and luks_holder */ if (!update_info_luks (device)) goto out; /* device_is_luks_cleartext and luks_cleartext_* properties */ if (!update_info_luks_cleartext (device)) goto out; #ifdef HAVE_LVM2 /* device_is_linux_lvm2_lv and linux_lvm2_lv_* properties */ if (!update_info_linux_lvm2_lv (device)) goto out; /* device_is_linux_lvm2_pv and linux_lvm2_pv_* properties */ if (!update_info_linux_lvm2_pv (device)) goto out; #endif #ifdef HAVE_DMMP /* device_is_linux_dmmp and linux_dmmp_* properties */ if (!update_info_linux_dmmp (device)) goto out; /* device_is_partition and partition_* properties for dm-0 "partitions" on a multi-path device */ if (!update_info_partition_on_linux_dmmp (device)) goto out; /* device_is_linux_dmmp_component and linux_dmmp_component_* properties */ if (!update_info_linux_dmmp_component (device)) goto out; #endif /* device_is_linux_md_component and linux_md_component_* properties */ if (!update_info_linux_md_component (device)) goto out; /* device_is_linux_md and linux_md_* properties */ if (!update_info_linux_md (device)) goto out; /* drive_ata_smart_* properties */ if (!update_info_drive_ata_smart (device)) goto out; /* drive_can_spindown property */ if (!update_info_drive_can_spindown (device)) goto out; /* device_is_system_internal property */ if (!update_info_is_system_internal (device)) goto out; /* device_is_mounted, device_mount, device_mounted_by_uid */ if (!update_info_mount_state (device)) goto out; /* device_is_media_change_detected, device_is_media_change_detection_* properties */ if (!update_info_media_detection (device)) goto out; /* drive_adapter proprety */ if (!update_info_drive_adapter (device)) goto out; /* drive_ports property */ if (!update_info_drive_ports (device)) goto out; /* drive_similar_devices property */ if (!update_info_drive_similar_devices (device)) goto out; ret = TRUE; out: /* Now check if holders/ or slaves/ has changed since last update. We compute * the delta and do update_info() on each holder/slave that has been * added/removed. * * Note that this won't trigger an endless loop since we look at the diffs. * * We have to do this because the kernel doesn't generate any 'change' event * when slaves/ or holders/ change. This is unfortunate because we *need* such * a change event to update properties devices (for example: luks_holder). * * We do the update in idle because the update may depend on the device * currently being processed being added. */ cur_slaves_objpath = dup_list_from_ptrarray (device->priv->slaves_objpath); cur_holders_objpath = dup_list_from_ptrarray (device->priv->holders_objpath); old_slaves_objpath = g_list_sort (old_slaves_objpath, (GCompareFunc) g_strcmp0); old_holders_objpath = g_list_sort (old_holders_objpath, (GCompareFunc) g_strcmp0); cur_slaves_objpath = g_list_sort (cur_slaves_objpath, (GCompareFunc) g_strcmp0); cur_holders_objpath = g_list_sort (cur_holders_objpath, (GCompareFunc) g_strcmp0); diff_sorted_lists (old_slaves_objpath, cur_slaves_objpath, (GCompareFunc) g_strcmp0, &added_objpath, &removed_objpath); for (l = added_objpath; l != NULL; l = l->next) { const gchar *objpath2 = l->data; Device *device2; device2 = daemon_local_find_by_object_path (device->priv->daemon, objpath2); if (device2 != NULL) { update_info_in_idle (device2); } else { g_print ("**** NOTE: %s added non-existant slave %s\n", device->priv->object_path, objpath2); } } for (l = removed_objpath; l != NULL; l = l->next) { const gchar *objpath2 = l->data; Device *device2; device2 = daemon_local_find_by_object_path (device->priv->daemon, objpath2); if (device2 != NULL) { update_info_in_idle (device2); } else { } } g_list_free (added_objpath); g_list_free (removed_objpath); diff_sorted_lists (old_holders_objpath, cur_holders_objpath, (GCompareFunc) g_strcmp0, &added_objpath, &removed_objpath); for (l = added_objpath; l != NULL; l = l->next) { const gchar *objpath2 = l->data; Device *device2; device2 = daemon_local_find_by_object_path (device->priv->daemon, objpath2); if (device2 != NULL) { update_info_in_idle (device2); } else { g_print ("**** NOTE: %s added non-existant holder %s\n", device->priv->object_path, objpath2); } } for (l = removed_objpath; l != NULL; l = l->next) { const gchar *objpath2 = l->data; Device *device2; device2 = daemon_local_find_by_object_path (device->priv->daemon, objpath2); if (device2 != NULL) { update_info_in_idle (device2); } else { } } g_list_free (added_objpath); g_list_free (removed_objpath); g_list_foreach (old_slaves_objpath, (GFunc) g_free, NULL); g_list_free (old_slaves_objpath); g_list_foreach (old_holders_objpath, (GFunc) g_free, NULL); g_list_free (old_holders_objpath); g_list_foreach (cur_slaves_objpath, (GFunc) g_free, NULL); g_list_free (cur_slaves_objpath); g_list_foreach (cur_holders_objpath, (GFunc) g_free, NULL); g_list_free (cur_holders_objpath); PROFILE ("update_info(device=%s) end", device->priv->native_path); return ret; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,432
update_info_drive_adapter (Device *device) { Adapter *adapter; const gchar *adapter_object_path; adapter_object_path = NULL; adapter = daemon_local_find_enclosing_adapter (device->priv->daemon, device->priv->native_path); if (adapter != NULL) { adapter_object_path = adapter_local_get_object_path (adapter); } device_set_drive_adapter (device, adapter_object_path); return TRUE; }
+Info
0
update_info_drive_adapter (Device *device) { Adapter *adapter; const gchar *adapter_object_path; adapter_object_path = NULL; adapter = daemon_local_find_enclosing_adapter (device->priv->daemon, device->priv->native_path); if (adapter != NULL) { adapter_object_path = adapter_local_get_object_path (adapter); } device_set_drive_adapter (device, adapter_object_path); return TRUE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,433
update_info_drive_ata_smart (Device *device) { gboolean ata_smart_is_available; ata_smart_is_available = FALSE; if (device->priv->device_is_drive && g_udev_device_has_property (device->priv->d, "UDISKS_ATA_SMART_IS_AVAILABLE")) ata_smart_is_available = g_udev_device_get_property_as_boolean (device->priv->d, "UDISKS_ATA_SMART_IS_AVAILABLE"); device_set_drive_ata_smart_is_available (device, ata_smart_is_available); /* NOTE: we don't collect ATA SMART data here, we only set whether the device is ATA SMART capable; * collecting data is done in separate routines, see the * device_drive_ata_smart_refresh_data() function for details. */ return TRUE; }
+Info
0
update_info_drive_ata_smart (Device *device) { gboolean ata_smart_is_available; ata_smart_is_available = FALSE; if (device->priv->device_is_drive && g_udev_device_has_property (device->priv->d, "UDISKS_ATA_SMART_IS_AVAILABLE")) ata_smart_is_available = g_udev_device_get_property_as_boolean (device->priv->d, "UDISKS_ATA_SMART_IS_AVAILABLE"); device_set_drive_ata_smart_is_available (device, ata_smart_is_available); /* NOTE: we don't collect ATA SMART data here, we only set whether the device is ATA SMART capable; * collecting data is done in separate routines, see the * device_drive_ata_smart_refresh_data() function for details. */ return TRUE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,434
update_info_drive_ports (Device *device) { GList *ports; GList *l; GPtrArray *p; ports = daemon_local_find_enclosing_ports (device->priv->daemon, device->priv->native_path); p = g_ptr_array_new (); for (l = ports; l != NULL; l = l->next) { Port *port = PORT (l->data); g_ptr_array_add (p, (gpointer) port_local_get_object_path (port)); } g_ptr_array_add (p, NULL); device_set_drive_ports (device, (GStrv) p->pdata); g_ptr_array_unref (p); g_list_free (ports); return TRUE; }
+Info
0
update_info_drive_ports (Device *device) { GList *ports; GList *l; GPtrArray *p; ports = daemon_local_find_enclosing_ports (device->priv->daemon, device->priv->native_path); p = g_ptr_array_new (); for (l = ports; l != NULL; l = l->next) { Port *port = PORT (l->data); g_ptr_array_add (p, (gpointer) port_local_get_object_path (port)); } g_ptr_array_add (p, NULL); device_set_drive_ports (device, (GStrv) p->pdata); g_ptr_array_unref (p); g_list_free (ports); return TRUE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,435
update_info_drive_similar_devices (Device *device) { GList *devices; GList *l; GPtrArray *p; p = g_ptr_array_new (); if (!device->priv->device_is_drive) goto out; /* We need non-empty SERIAL and WWN for this to work */ if ((device->priv->drive_serial == NULL || strlen (device->priv->drive_serial) == 0) || (device->priv->drive_wwn == NULL || strlen (device->priv->drive_wwn) == 0)) goto out; /* TODO: this might be slow - if so, use a hash on the Daemon class */ devices = daemon_local_get_all_devices (device->priv->daemon); for (l = devices; l != NULL; l = l->next) { Device *d = DEVICE (l->data); if (!d->priv->device_is_drive) continue; if (d == device) continue; #if 0 g_debug ("looking at %s:\n" " %s\n" " %s\n" " %s\n" " %s\n", d->priv->device_file, d->priv->drive_serial, device->priv->drive_serial, d->priv->drive_wwn, device->priv->drive_wwn); #endif /* current policy is that *both* SERIAL and WWN must match */ if (g_strcmp0 (d->priv->drive_serial, device->priv->drive_serial) == 0 && g_strcmp0 (d->priv->drive_wwn, device->priv->drive_wwn) == 0) { g_ptr_array_add (p, d->priv->object_path); /* ensure that the device we added also exists in its own drive_similar_devices property */ if (!ptr_array_has_string (d->priv->drive_similar_devices, device->priv->object_path)) { update_info_in_idle (d); } else { } } } out: g_ptr_array_add (p, NULL); device_set_drive_similar_devices (device, (GStrv) p->pdata); g_ptr_array_free (p, TRUE); return TRUE; }
+Info
0
update_info_drive_similar_devices (Device *device) { GList *devices; GList *l; GPtrArray *p; p = g_ptr_array_new (); if (!device->priv->device_is_drive) goto out; /* We need non-empty SERIAL and WWN for this to work */ if ((device->priv->drive_serial == NULL || strlen (device->priv->drive_serial) == 0) || (device->priv->drive_wwn == NULL || strlen (device->priv->drive_wwn) == 0)) goto out; /* TODO: this might be slow - if so, use a hash on the Daemon class */ devices = daemon_local_get_all_devices (device->priv->daemon); for (l = devices; l != NULL; l = l->next) { Device *d = DEVICE (l->data); if (!d->priv->device_is_drive) continue; if (d == device) continue; #if 0 g_debug ("looking at %s:\n" " %s\n" " %s\n" " %s\n" " %s\n", d->priv->device_file, d->priv->drive_serial, device->priv->drive_serial, d->priv->drive_wwn, device->priv->drive_wwn); #endif /* current policy is that *both* SERIAL and WWN must match */ if (g_strcmp0 (d->priv->drive_serial, device->priv->drive_serial) == 0 && g_strcmp0 (d->priv->drive_wwn, device->priv->drive_wwn) == 0) { g_ptr_array_add (p, d->priv->object_path); /* ensure that the device we added also exists in its own drive_similar_devices property */ if (!ptr_array_has_string (d->priv->drive_similar_devices, device->priv->object_path)) { update_info_in_idle (d); } else { } } } out: g_ptr_array_add (p, NULL); device_set_drive_similar_devices (device, (GStrv) p->pdata); g_ptr_array_free (p, TRUE); return TRUE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,436
update_info_id (Device *device) { gchar *decoded_string; const gchar *partition_scheme; gint partition_type; partition_scheme = g_udev_device_get_property (device->priv->d, "UDISKS_PARTITION_SCHEME"); partition_type = g_udev_device_get_property_as_int (device->priv->d, "UDISKS_PARTITION_TYPE"); if (g_strcmp0 (partition_scheme, "mbr") == 0 && (partition_type == 0x05 || partition_type == 0x0f || partition_type == 0x85)) { device_set_id_usage (device, ""); device_set_id_type (device, ""); device_set_id_version (device, ""); device_set_id_label (device, ""); device_set_id_uuid (device, ""); goto out; } device_set_id_usage (device, g_udev_device_get_property (device->priv->d, "ID_FS_USAGE")); device_set_id_type (device, g_udev_device_get_property (device->priv->d, "ID_FS_TYPE")); device_set_id_version (device, g_udev_device_get_property (device->priv->d, "ID_FS_VERSION")); if (g_udev_device_has_property (device->priv->d, "ID_FS_LABEL_ENC")) { decoded_string = decode_udev_encoded_string (g_udev_device_get_property (device->priv->d, "ID_FS_LABEL_ENC")); device_set_id_label (device, decoded_string); g_free (decoded_string); } else { device_set_id_label (device, g_udev_device_get_property (device->priv->d, "ID_FS_LABEL")); } device_set_id_uuid (device, g_udev_device_get_property (device->priv->d, "ID_FS_UUID")); out: return TRUE; }
+Info
0
update_info_id (Device *device) { gchar *decoded_string; const gchar *partition_scheme; gint partition_type; partition_scheme = g_udev_device_get_property (device->priv->d, "UDISKS_PARTITION_SCHEME"); partition_type = g_udev_device_get_property_as_int (device->priv->d, "UDISKS_PARTITION_TYPE"); if (g_strcmp0 (partition_scheme, "mbr") == 0 && (partition_type == 0x05 || partition_type == 0x0f || partition_type == 0x85)) { device_set_id_usage (device, ""); device_set_id_type (device, ""); device_set_id_version (device, ""); device_set_id_label (device, ""); device_set_id_uuid (device, ""); goto out; } device_set_id_usage (device, g_udev_device_get_property (device->priv->d, "ID_FS_USAGE")); device_set_id_type (device, g_udev_device_get_property (device->priv->d, "ID_FS_TYPE")); device_set_id_version (device, g_udev_device_get_property (device->priv->d, "ID_FS_VERSION")); if (g_udev_device_has_property (device->priv->d, "ID_FS_LABEL_ENC")) { decoded_string = decode_udev_encoded_string (g_udev_device_get_property (device->priv->d, "ID_FS_LABEL_ENC")); device_set_id_label (device, decoded_string); g_free (decoded_string); } else { device_set_id_label (device, g_udev_device_get_property (device->priv->d, "ID_FS_LABEL")); } device_set_id_uuid (device, g_udev_device_get_property (device->priv->d, "ID_FS_UUID")); out: return TRUE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,437
update_info_in_idle (Device *device) { UpdateInfoInIdleData *data; data = g_new0 (UpdateInfoInIdleData, 1); data->device = device; data->idle_id = g_idle_add_full (G_PRIORITY_HIGH_IDLE, update_info_in_idle_cb, data, (GDestroyNotify) update_info_in_idle_data_free); g_object_weak_ref (G_OBJECT (device), update_info_in_idle_device_unreffed, data); }
+Info
0
update_info_in_idle (Device *device) { UpdateInfoInIdleData *data; data = g_new0 (UpdateInfoInIdleData, 1); data->device = device; data->idle_id = g_idle_add_full (G_PRIORITY_HIGH_IDLE, update_info_in_idle_cb, data, (GDestroyNotify) update_info_in_idle_data_free); g_object_weak_ref (G_OBJECT (device), update_info_in_idle_device_unreffed, data); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,438
update_info_in_idle_cb (gpointer user_data) { UpdateInfoInIdleData *data = user_data; /* this indirectly calls update_info and also removes the device * if it wants to be removed (e.g. if update_info() returns FALSE) */ daemon_local_synthesize_changed (data->device->priv->daemon, data->device); return FALSE; /* remove source */ }
+Info
0
update_info_in_idle_cb (gpointer user_data) { UpdateInfoInIdleData *data = user_data; /* this indirectly calls update_info and also removes the device * if it wants to be removed (e.g. if update_info() returns FALSE) */ daemon_local_synthesize_changed (data->device->priv->daemon, data->device); return FALSE; /* remove source */ }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,439
update_info_in_idle_data_free (UpdateInfoInIdleData *data) { g_object_weak_unref (G_OBJECT (data->device), update_info_in_idle_device_unreffed, data); g_free (data); }
+Info
0
update_info_in_idle_data_free (UpdateInfoInIdleData *data) { g_object_weak_unref (G_OBJECT (data->device), update_info_in_idle_device_unreffed, data); g_free (data); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,440
update_info_in_idle_device_unreffed (gpointer user_data, GObject *where_the_object_was) { UpdateInfoInIdleData *data = user_data; g_source_remove (data->idle_id); }
+Info
0
update_info_in_idle_device_unreffed (gpointer user_data, GObject *where_the_object_was) { UpdateInfoInIdleData *data = user_data; g_source_remove (data->idle_id); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,441
update_info_is_system_internal (Device *device) { gboolean is_system_internal; /* TODO: make it possible to override this property from a udev property. */ /* start out by assuming the device is system internal, then adjust depending on what kind of * device we are dealing with */ is_system_internal = TRUE; /* A Linux MD device is system internal if, and only if * * - a single component is system internal * - there are no components */ if (device->priv->device_is_linux_md) { is_system_internal = FALSE; if (device->priv->slaves_objpath->len == 0) { is_system_internal = TRUE; } else { guint n; for (n = 0; n < device->priv->slaves_objpath->len; n++) { const gchar *slave_objpath; Device *slave; slave_objpath = device->priv->slaves_objpath->pdata[n]; slave = daemon_local_find_by_object_path (device->priv->daemon, slave_objpath); if (slave == NULL) continue; if (slave->priv->device_is_system_internal) { is_system_internal = TRUE; break; } } } goto determined; } /* a partition is system internal only if the drive it belongs to is system internal */ if (device->priv->device_is_partition) { Device *enclosing_device; enclosing_device = daemon_local_find_by_object_path (device->priv->daemon, device->priv->partition_slave); if (enclosing_device != NULL) { is_system_internal = enclosing_device->priv->device_is_system_internal; } else { is_system_internal = TRUE; } goto determined; } /* a LUKS cleartext device is system internal only if the underlying crypto-text * device is system internal */ if (device->priv->device_is_luks_cleartext) { Device *enclosing_device; enclosing_device = daemon_local_find_by_object_path (device->priv->daemon, device->priv->luks_cleartext_slave); if (enclosing_device != NULL) { is_system_internal = enclosing_device->priv->device_is_system_internal; } else { is_system_internal = TRUE; } goto determined; } /* devices with removable media are never system internal */ if (device->priv->device_is_removable) { is_system_internal = FALSE; goto determined; } /* devices on certain buses are never system internal */ if (device->priv->device_is_drive && device->priv->drive_connection_interface != NULL) { if (strcmp (device->priv->drive_connection_interface, "ata_serial_esata") == 0 || strcmp (device->priv->drive_connection_interface, "sdio") == 0 || strcmp (device->priv->drive_connection_interface, "usb") == 0 || strcmp (device->priv->drive_connection_interface, "firewire") == 0) { is_system_internal = FALSE; } else { is_system_internal = TRUE; } goto determined; } determined: device_set_device_is_system_internal (device, is_system_internal); return TRUE; }
+Info
0
update_info_is_system_internal (Device *device) { gboolean is_system_internal; /* TODO: make it possible to override this property from a udev property. */ /* start out by assuming the device is system internal, then adjust depending on what kind of * device we are dealing with */ is_system_internal = TRUE; /* A Linux MD device is system internal if, and only if * * - a single component is system internal * - there are no components */ if (device->priv->device_is_linux_md) { is_system_internal = FALSE; if (device->priv->slaves_objpath->len == 0) { is_system_internal = TRUE; } else { guint n; for (n = 0; n < device->priv->slaves_objpath->len; n++) { const gchar *slave_objpath; Device *slave; slave_objpath = device->priv->slaves_objpath->pdata[n]; slave = daemon_local_find_by_object_path (device->priv->daemon, slave_objpath); if (slave == NULL) continue; if (slave->priv->device_is_system_internal) { is_system_internal = TRUE; break; } } } goto determined; } /* a partition is system internal only if the drive it belongs to is system internal */ if (device->priv->device_is_partition) { Device *enclosing_device; enclosing_device = daemon_local_find_by_object_path (device->priv->daemon, device->priv->partition_slave); if (enclosing_device != NULL) { is_system_internal = enclosing_device->priv->device_is_system_internal; } else { is_system_internal = TRUE; } goto determined; } /* a LUKS cleartext device is system internal only if the underlying crypto-text * device is system internal */ if (device->priv->device_is_luks_cleartext) { Device *enclosing_device; enclosing_device = daemon_local_find_by_object_path (device->priv->daemon, device->priv->luks_cleartext_slave); if (enclosing_device != NULL) { is_system_internal = enclosing_device->priv->device_is_system_internal; } else { is_system_internal = TRUE; } goto determined; } /* devices with removable media are never system internal */ if (device->priv->device_is_removable) { is_system_internal = FALSE; goto determined; } /* devices on certain buses are never system internal */ if (device->priv->device_is_drive && device->priv->drive_connection_interface != NULL) { if (strcmp (device->priv->drive_connection_interface, "ata_serial_esata") == 0 || strcmp (device->priv->drive_connection_interface, "sdio") == 0 || strcmp (device->priv->drive_connection_interface, "usb") == 0 || strcmp (device->priv->drive_connection_interface, "firewire") == 0) { is_system_internal = FALSE; } else { is_system_internal = TRUE; } goto determined; } determined: device_set_device_is_system_internal (device, is_system_internal); return TRUE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,442
update_info_linux_loop (Device *device) { gboolean ret; gint fd; struct loop_info64 loop_info_buf; gboolean is_loop; gchar *s; gchar *s2; is_loop = FALSE; ret = FALSE; fd = -1; if (!g_str_has_prefix (device->priv->native_path, "/sys/devices/virtual/block/loop")) { ret = TRUE; goto out; } fd = open (device->priv->device_file, O_RDONLY); if (fd < 0) goto out; if (ioctl (fd, LOOP_GET_STATUS64, &loop_info_buf) != 0) goto out; /* TODO: is lo_file_name really NUL-terminated? */ device_set_linux_loop_filename (device, (const gchar *) loop_info_buf.lo_file_name); ret = TRUE; is_loop = TRUE; device_set_drive_vendor (device, "Linux"); s2 = g_path_get_basename ((gchar *) loop_info_buf.lo_file_name); s = g_strdup_printf ("Loop: %s", s2); g_free (s2); device_set_drive_model (device, s); g_free (s); out: if (fd > 0) close (fd); device_set_device_is_linux_loop (device, is_loop); return ret; }
+Info
0
update_info_linux_loop (Device *device) { gboolean ret; gint fd; struct loop_info64 loop_info_buf; gboolean is_loop; gchar *s; gchar *s2; is_loop = FALSE; ret = FALSE; fd = -1; if (!g_str_has_prefix (device->priv->native_path, "/sys/devices/virtual/block/loop")) { ret = TRUE; goto out; } fd = open (device->priv->device_file, O_RDONLY); if (fd < 0) goto out; if (ioctl (fd, LOOP_GET_STATUS64, &loop_info_buf) != 0) goto out; /* TODO: is lo_file_name really NUL-terminated? */ device_set_linux_loop_filename (device, (const gchar *) loop_info_buf.lo_file_name); ret = TRUE; is_loop = TRUE; device_set_drive_vendor (device, "Linux"); s2 = g_path_get_basename ((gchar *) loop_info_buf.lo_file_name); s = g_strdup_printf ("Loop: %s", s2); g_free (s2); device_set_drive_model (device, s); g_free (s); out: if (fd > 0) close (fd); device_set_device_is_linux_loop (device, is_loop); return ret; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,443
update_info_linux_lvm2_lv (Device *device) { const gchar *lv_name; const gchar *vg_name; const gchar *uuid; gchar *lv_uuid; gchar *vg_uuid; gboolean is_lv; is_lv = FALSE; lv_uuid = NULL; vg_uuid = NULL; lv_name = g_udev_device_get_property (device->priv->d, "DM_LV_NAME"); vg_name = g_udev_device_get_property (device->priv->d, "DM_VG_NAME"); if (lv_name == NULL || vg_name == NULL) goto out; uuid = g_udev_device_get_sysfs_attr (device->priv->d, "dm/uuid"); if (uuid == NULL || !g_str_has_prefix (uuid, "LVM-")) goto out; vg_uuid = extract_lvm_uuid (uuid + 4); if (vg_uuid == NULL) goto out; lv_uuid = extract_lvm_uuid (uuid + 4 + 32); if (lv_uuid == NULL) goto out; is_lv = TRUE; device_set_linux_lvm2_lv_name (device, lv_name); device_set_linux_lvm2_lv_uuid (device, lv_uuid); device_set_linux_lvm2_lv_group_name (device, vg_name); device_set_linux_lvm2_lv_group_uuid (device, vg_uuid); device_set_device_is_drive (device, FALSE); device_set_device_is_partition (device, FALSE); out: device_set_device_is_linux_lvm2_lv (device, is_lv); g_free (vg_uuid); g_free (lv_uuid); return TRUE; }
+Info
0
update_info_linux_lvm2_lv (Device *device) { const gchar *lv_name; const gchar *vg_name; const gchar *uuid; gchar *lv_uuid; gchar *vg_uuid; gboolean is_lv; is_lv = FALSE; lv_uuid = NULL; vg_uuid = NULL; lv_name = g_udev_device_get_property (device->priv->d, "DM_LV_NAME"); vg_name = g_udev_device_get_property (device->priv->d, "DM_VG_NAME"); if (lv_name == NULL || vg_name == NULL) goto out; uuid = g_udev_device_get_sysfs_attr (device->priv->d, "dm/uuid"); if (uuid == NULL || !g_str_has_prefix (uuid, "LVM-")) goto out; vg_uuid = extract_lvm_uuid (uuid + 4); if (vg_uuid == NULL) goto out; lv_uuid = extract_lvm_uuid (uuid + 4 + 32); if (lv_uuid == NULL) goto out; is_lv = TRUE; device_set_linux_lvm2_lv_name (device, lv_name); device_set_linux_lvm2_lv_uuid (device, lv_uuid); device_set_linux_lvm2_lv_group_name (device, vg_name); device_set_linux_lvm2_lv_group_uuid (device, vg_uuid); device_set_device_is_drive (device, FALSE); device_set_device_is_partition (device, FALSE); out: device_set_device_is_linux_lvm2_lv (device, is_lv); g_free (vg_uuid); g_free (lv_uuid); return TRUE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,444
update_info_linux_lvm2_pv (Device *device) { const gchar *pv_uuid; guint64 pv_num_mda; const gchar *vg_name; const gchar *vg_uuid; gboolean is_pv; guint64 vg_size; guint64 vg_unallocated_size; guint64 vg_extent_size; guint64 vg_seqnum; const gchar* const *vg_pvs; const gchar* const *vg_lvs; pv_uuid = g_udev_device_get_property (device->priv->d, "UDISKS_LVM2_PV_UUID"); pv_num_mda = g_udev_device_get_property_as_uint64 (device->priv->d, "UDISKS_LVM2_PV_NUM_MDA"); vg_name = g_udev_device_get_property (device->priv->d, "UDISKS_LVM2_PV_VG_NAME"); vg_uuid = g_udev_device_get_property (device->priv->d, "UDISKS_LVM2_PV_VG_UUID"); vg_size = g_udev_device_get_property_as_uint64 (device->priv->d, "UDISKS_LVM2_PV_VG_SIZE"); vg_unallocated_size = g_udev_device_get_property_as_uint64 (device->priv->d, "UDISKS_LVM2_PV_VG_FREE_SIZE"); vg_extent_size = g_udev_device_get_property_as_uint64 (device->priv->d, "UDISKS_LVM2_PV_VG_EXTENT_SIZE"); vg_seqnum = g_udev_device_get_property_as_uint64 (device->priv->d, "UDISKS_LVM2_PV_VG_SEQNUM"); vg_pvs = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_LVM2_PV_VG_PV_LIST"); vg_lvs = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_LVM2_PV_VG_LV_LIST"); is_pv = FALSE; if (pv_uuid == NULL) goto out; is_pv = TRUE; device_set_linux_lvm2_pv_uuid (device, pv_uuid); device_set_linux_lvm2_pv_num_metadata_areas (device, pv_num_mda); device_set_linux_lvm2_pv_group_name (device, vg_name); device_set_linux_lvm2_pv_group_uuid (device, vg_uuid); device_set_linux_lvm2_pv_group_size (device, vg_size); device_set_linux_lvm2_pv_group_unallocated_size (device, vg_unallocated_size); device_set_linux_lvm2_pv_group_extent_size (device, vg_extent_size); device_set_linux_lvm2_pv_group_sequence_number (device, vg_seqnum); device_set_linux_lvm2_pv_group_physical_volumes (device, (GStrv) vg_pvs); device_set_linux_lvm2_pv_group_logical_volumes (device, (GStrv) vg_lvs); out: device_set_device_is_linux_lvm2_pv (device, is_pv); return TRUE; }
+Info
0
update_info_linux_lvm2_pv (Device *device) { const gchar *pv_uuid; guint64 pv_num_mda; const gchar *vg_name; const gchar *vg_uuid; gboolean is_pv; guint64 vg_size; guint64 vg_unallocated_size; guint64 vg_extent_size; guint64 vg_seqnum; const gchar* const *vg_pvs; const gchar* const *vg_lvs; pv_uuid = g_udev_device_get_property (device->priv->d, "UDISKS_LVM2_PV_UUID"); pv_num_mda = g_udev_device_get_property_as_uint64 (device->priv->d, "UDISKS_LVM2_PV_NUM_MDA"); vg_name = g_udev_device_get_property (device->priv->d, "UDISKS_LVM2_PV_VG_NAME"); vg_uuid = g_udev_device_get_property (device->priv->d, "UDISKS_LVM2_PV_VG_UUID"); vg_size = g_udev_device_get_property_as_uint64 (device->priv->d, "UDISKS_LVM2_PV_VG_SIZE"); vg_unallocated_size = g_udev_device_get_property_as_uint64 (device->priv->d, "UDISKS_LVM2_PV_VG_FREE_SIZE"); vg_extent_size = g_udev_device_get_property_as_uint64 (device->priv->d, "UDISKS_LVM2_PV_VG_EXTENT_SIZE"); vg_seqnum = g_udev_device_get_property_as_uint64 (device->priv->d, "UDISKS_LVM2_PV_VG_SEQNUM"); vg_pvs = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_LVM2_PV_VG_PV_LIST"); vg_lvs = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_LVM2_PV_VG_LV_LIST"); is_pv = FALSE; if (pv_uuid == NULL) goto out; is_pv = TRUE; device_set_linux_lvm2_pv_uuid (device, pv_uuid); device_set_linux_lvm2_pv_num_metadata_areas (device, pv_num_mda); device_set_linux_lvm2_pv_group_name (device, vg_name); device_set_linux_lvm2_pv_group_uuid (device, vg_uuid); device_set_linux_lvm2_pv_group_size (device, vg_size); device_set_linux_lvm2_pv_group_unallocated_size (device, vg_unallocated_size); device_set_linux_lvm2_pv_group_extent_size (device, vg_extent_size); device_set_linux_lvm2_pv_group_sequence_number (device, vg_seqnum); device_set_linux_lvm2_pv_group_physical_volumes (device, (GStrv) vg_pvs); device_set_linux_lvm2_pv_group_logical_volumes (device, (GStrv) vg_lvs); out: device_set_device_is_linux_lvm2_pv (device, is_pv); return TRUE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,445
update_info_linux_md (Device *device) { gboolean ret; guint n; gchar *s; gchar *p; ret = FALSE; if (sysfs_file_exists (device->priv->native_path, "md")) { gchar *uuid; gint num_raid_devices; gchar *raid_level; gchar *array_state; Device *slave; GPtrArray *md_slaves; const gchar *md_name; const gchar *md_home_host; device_set_device_is_linux_md (device, TRUE); /* figure out if the array is active */ array_state = sysfs_get_string (device->priv->native_path, "md/array_state"); if (array_state == NULL) { g_print ("**** NOTE: Linux MD array %s has no array_state file'; removing\n", device->priv->native_path); goto out; } g_strstrip (array_state); /* ignore clear arrays since these have no devices, no size, no level */ if (strcmp (array_state, "clear") == 0) { g_print ("**** NOTE: Linux MD array %s is 'clear'; removing\n", device->priv->native_path); g_free (array_state); goto out; } device_set_linux_md_state (device, array_state); g_free (array_state); /* find a slave from the array */ slave = NULL; for (n = 0; n < device->priv->slaves_objpath->len; n++) { const gchar *slave_objpath; slave_objpath = device->priv->slaves_objpath->pdata[n]; slave = daemon_local_find_by_object_path (device->priv->daemon, slave_objpath); if (slave != NULL) break; } uuid = g_strdup (g_udev_device_get_property (device->priv->d, "MD_UUID")); num_raid_devices = sysfs_get_int (device->priv->native_path, "md/raid_disks"); raid_level = g_strstrip (sysfs_get_string (device->priv->native_path, "md/level")); if (slave != NULL) { /* if the UUID isn't set by the udev rules (array may be inactive) get it from a slave */ if (uuid == NULL || strlen (uuid) == 0) { g_free (uuid); uuid = g_strdup (slave->priv->linux_md_component_uuid); } /* ditto for raid level */ if (raid_level == NULL || strlen (raid_level) == 0) { g_free (raid_level); raid_level = g_strdup (slave->priv->linux_md_component_level); } /* and num_raid_devices too */ if (device->priv->linux_md_num_raid_devices == 0) { num_raid_devices = slave->priv->linux_md_component_num_raid_devices; } } device_set_linux_md_uuid (device, uuid); device_set_linux_md_num_raid_devices (device, num_raid_devices); device_set_linux_md_level (device, raid_level); g_free (raid_level); g_free (uuid); /* infer the array name and homehost */ p = g_strdup (g_udev_device_get_property (device->priv->d, "MD_NAME")); s = NULL; if (p != NULL) s = strstr (p, ":"); if (s != NULL) { *s = '\0'; md_home_host = p; md_name = s + 1; } else { md_home_host = ""; md_name = p; } device_set_linux_md_home_host (device, md_home_host); device_set_linux_md_name (device, md_name); g_free (p); s = g_strstrip (sysfs_get_string (device->priv->native_path, "md/metadata_version")); device_set_linux_md_version (device, s); g_free (s); /* Go through all block slaves and build up the linux_md_slaves property * * Also update the slaves since the slave state may have changed. */ md_slaves = g_ptr_array_new (); for (n = 0; n < device->priv->slaves_objpath->len; n++) { Device *slave_device; const gchar *slave_objpath; slave_objpath = device->priv->slaves_objpath->pdata[n]; g_ptr_array_add (md_slaves, (gpointer) slave_objpath); slave_device = daemon_local_find_by_object_path (device->priv->daemon, slave_objpath); if (slave_device != NULL) { update_info (slave_device); } } g_ptr_array_sort (md_slaves, (GCompareFunc) ptr_str_array_compare); g_ptr_array_add (md_slaves, NULL); device_set_linux_md_slaves (device, (GStrv) md_slaves->pdata); g_ptr_array_free (md_slaves, TRUE); /* TODO: may race */ device_set_drive_vendor (device, "Linux"); if (device->priv->linux_md_level != NULL) s = g_strdup_printf ("Software RAID %s", device->priv->linux_md_level); else s = g_strdup_printf ("Software RAID"); device_set_drive_model (device, s); g_free (s); device_set_drive_revision (device, device->priv->linux_md_version); device_set_drive_connection_interface (device, "virtual"); device_set_drive_serial (device, device->priv->linux_md_uuid); /* RAID-0 can never resync or run degraded */ if (g_strcmp0 (device->priv->linux_md_level, "raid0") == 0 || g_strcmp0 (device->priv->linux_md_level, "linear") == 0) { device_set_linux_md_sync_action (device, "idle"); device_set_linux_md_is_degraded (device, FALSE); } else { gchar *degraded_file; gint num_degraded_devices; degraded_file = sysfs_get_string (device->priv->native_path, "md/degraded"); if (degraded_file == NULL) { num_degraded_devices = 0; } else { num_degraded_devices = strtol (degraded_file, NULL, 0); } g_free (degraded_file); device_set_linux_md_is_degraded (device, (num_degraded_devices > 0)); s = g_strstrip (sysfs_get_string (device->priv->native_path, "md/sync_action")); device_set_linux_md_sync_action (device, s); g_free (s); if (device->priv->linux_md_sync_action == NULL || strlen (device->priv->linux_md_sync_action) == 0) { device_set_linux_md_sync_action (device, "idle"); } /* if not idle; update percentage and speed */ if (g_strcmp0 (device->priv->linux_md_sync_action, "idle") != 0) { char *s; guint64 done; guint64 remaining; s = g_strstrip (sysfs_get_string (device->priv->native_path, "md/sync_completed")); if (sscanf (s, "%" G_GUINT64_FORMAT " / %" G_GUINT64_FORMAT "", &done, &remaining) == 2) { device_set_linux_md_sync_percentage (device, 100.0 * ((double) done) / ((double) remaining)); } else { g_warning ("cannot parse md/sync_completed for %s: '%s'", device->priv->native_path, s); } g_free (s); device_set_linux_md_sync_speed (device, 1000L * sysfs_get_uint64 (device->priv->native_path, "md/sync_speed")); /* Since the kernel doesn't emit uevents while the job is pending, set up * a timeout for every two seconds to synthesize the change event so we can * refresh the completed/speed properties. */ if (device->priv->linux_md_poll_timeout_id == 0) { device->priv->linux_md_poll_timeout_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, 2, poll_syncing_md_device, g_object_ref (device), g_object_unref); } } else { device_set_linux_md_sync_percentage (device, 0.0); device_set_linux_md_sync_speed (device, 0); } } } else { device_set_device_is_linux_md (device, FALSE); device_set_linux_md_state (device, NULL); device_set_linux_md_level (device, NULL); device_set_linux_md_num_raid_devices (device, 0); device_set_linux_md_uuid (device, NULL); device_set_linux_md_home_host (device, NULL); device_set_linux_md_name (device, NULL); device_set_linux_md_version (device, NULL); device_set_linux_md_slaves (device, NULL); device_set_linux_md_is_degraded (device, FALSE); device_set_linux_md_sync_action (device, NULL); device_set_linux_md_sync_percentage (device, 0.0); device_set_linux_md_sync_speed (device, 0); } ret = TRUE; out: return ret; }
+Info
0
update_info_linux_md (Device *device) { gboolean ret; guint n; gchar *s; gchar *p; ret = FALSE; if (sysfs_file_exists (device->priv->native_path, "md")) { gchar *uuid; gint num_raid_devices; gchar *raid_level; gchar *array_state; Device *slave; GPtrArray *md_slaves; const gchar *md_name; const gchar *md_home_host; device_set_device_is_linux_md (device, TRUE); /* figure out if the array is active */ array_state = sysfs_get_string (device->priv->native_path, "md/array_state"); if (array_state == NULL) { g_print ("**** NOTE: Linux MD array %s has no array_state file'; removing\n", device->priv->native_path); goto out; } g_strstrip (array_state); /* ignore clear arrays since these have no devices, no size, no level */ if (strcmp (array_state, "clear") == 0) { g_print ("**** NOTE: Linux MD array %s is 'clear'; removing\n", device->priv->native_path); g_free (array_state); goto out; } device_set_linux_md_state (device, array_state); g_free (array_state); /* find a slave from the array */ slave = NULL; for (n = 0; n < device->priv->slaves_objpath->len; n++) { const gchar *slave_objpath; slave_objpath = device->priv->slaves_objpath->pdata[n]; slave = daemon_local_find_by_object_path (device->priv->daemon, slave_objpath); if (slave != NULL) break; } uuid = g_strdup (g_udev_device_get_property (device->priv->d, "MD_UUID")); num_raid_devices = sysfs_get_int (device->priv->native_path, "md/raid_disks"); raid_level = g_strstrip (sysfs_get_string (device->priv->native_path, "md/level")); if (slave != NULL) { /* if the UUID isn't set by the udev rules (array may be inactive) get it from a slave */ if (uuid == NULL || strlen (uuid) == 0) { g_free (uuid); uuid = g_strdup (slave->priv->linux_md_component_uuid); } /* ditto for raid level */ if (raid_level == NULL || strlen (raid_level) == 0) { g_free (raid_level); raid_level = g_strdup (slave->priv->linux_md_component_level); } /* and num_raid_devices too */ if (device->priv->linux_md_num_raid_devices == 0) { num_raid_devices = slave->priv->linux_md_component_num_raid_devices; } } device_set_linux_md_uuid (device, uuid); device_set_linux_md_num_raid_devices (device, num_raid_devices); device_set_linux_md_level (device, raid_level); g_free (raid_level); g_free (uuid); /* infer the array name and homehost */ p = g_strdup (g_udev_device_get_property (device->priv->d, "MD_NAME")); s = NULL; if (p != NULL) s = strstr (p, ":"); if (s != NULL) { *s = '\0'; md_home_host = p; md_name = s + 1; } else { md_home_host = ""; md_name = p; } device_set_linux_md_home_host (device, md_home_host); device_set_linux_md_name (device, md_name); g_free (p); s = g_strstrip (sysfs_get_string (device->priv->native_path, "md/metadata_version")); device_set_linux_md_version (device, s); g_free (s); /* Go through all block slaves and build up the linux_md_slaves property * * Also update the slaves since the slave state may have changed. */ md_slaves = g_ptr_array_new (); for (n = 0; n < device->priv->slaves_objpath->len; n++) { Device *slave_device; const gchar *slave_objpath; slave_objpath = device->priv->slaves_objpath->pdata[n]; g_ptr_array_add (md_slaves, (gpointer) slave_objpath); slave_device = daemon_local_find_by_object_path (device->priv->daemon, slave_objpath); if (slave_device != NULL) { update_info (slave_device); } } g_ptr_array_sort (md_slaves, (GCompareFunc) ptr_str_array_compare); g_ptr_array_add (md_slaves, NULL); device_set_linux_md_slaves (device, (GStrv) md_slaves->pdata); g_ptr_array_free (md_slaves, TRUE); /* TODO: may race */ device_set_drive_vendor (device, "Linux"); if (device->priv->linux_md_level != NULL) s = g_strdup_printf ("Software RAID %s", device->priv->linux_md_level); else s = g_strdup_printf ("Software RAID"); device_set_drive_model (device, s); g_free (s); device_set_drive_revision (device, device->priv->linux_md_version); device_set_drive_connection_interface (device, "virtual"); device_set_drive_serial (device, device->priv->linux_md_uuid); /* RAID-0 can never resync or run degraded */ if (g_strcmp0 (device->priv->linux_md_level, "raid0") == 0 || g_strcmp0 (device->priv->linux_md_level, "linear") == 0) { device_set_linux_md_sync_action (device, "idle"); device_set_linux_md_is_degraded (device, FALSE); } else { gchar *degraded_file; gint num_degraded_devices; degraded_file = sysfs_get_string (device->priv->native_path, "md/degraded"); if (degraded_file == NULL) { num_degraded_devices = 0; } else { num_degraded_devices = strtol (degraded_file, NULL, 0); } g_free (degraded_file); device_set_linux_md_is_degraded (device, (num_degraded_devices > 0)); s = g_strstrip (sysfs_get_string (device->priv->native_path, "md/sync_action")); device_set_linux_md_sync_action (device, s); g_free (s); if (device->priv->linux_md_sync_action == NULL || strlen (device->priv->linux_md_sync_action) == 0) { device_set_linux_md_sync_action (device, "idle"); } /* if not idle; update percentage and speed */ if (g_strcmp0 (device->priv->linux_md_sync_action, "idle") != 0) { char *s; guint64 done; guint64 remaining; s = g_strstrip (sysfs_get_string (device->priv->native_path, "md/sync_completed")); if (sscanf (s, "%" G_GUINT64_FORMAT " / %" G_GUINT64_FORMAT "", &done, &remaining) == 2) { device_set_linux_md_sync_percentage (device, 100.0 * ((double) done) / ((double) remaining)); } else { g_warning ("cannot parse md/sync_completed for %s: '%s'", device->priv->native_path, s); } g_free (s); device_set_linux_md_sync_speed (device, 1000L * sysfs_get_uint64 (device->priv->native_path, "md/sync_speed")); /* Since the kernel doesn't emit uevents while the job is pending, set up * a timeout for every two seconds to synthesize the change event so we can * refresh the completed/speed properties. */ if (device->priv->linux_md_poll_timeout_id == 0) { device->priv->linux_md_poll_timeout_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, 2, poll_syncing_md_device, g_object_ref (device), g_object_unref); } } else { device_set_linux_md_sync_percentage (device, 0.0); device_set_linux_md_sync_speed (device, 0); } } } else { device_set_device_is_linux_md (device, FALSE); device_set_linux_md_state (device, NULL); device_set_linux_md_level (device, NULL); device_set_linux_md_num_raid_devices (device, 0); device_set_linux_md_uuid (device, NULL); device_set_linux_md_home_host (device, NULL); device_set_linux_md_name (device, NULL); device_set_linux_md_version (device, NULL); device_set_linux_md_slaves (device, NULL); device_set_linux_md_is_degraded (device, FALSE); device_set_linux_md_sync_action (device, NULL); device_set_linux_md_sync_percentage (device, 0.0); device_set_linux_md_sync_speed (device, 0); } ret = TRUE; out: return ret; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,446
update_info_linux_md_component (Device *device) { if (g_strcmp0 (device->priv->id_type, "linux_raid_member") == 0) { const gchar *md_comp_level; gint md_comp_num_raid_devices; const gchar *md_comp_uuid; const gchar *md_comp_home_host; const gchar *md_comp_name; const gchar *md_comp_version; gchar *md_name; gchar *s; int md_comp_position; md_comp_position = -1; device_set_device_is_linux_md_component (device, TRUE); /* linux_md_component_holder and linux_md_component_state */ if (device->priv->holders_objpath->len == 1) { Device *holder; gchar **state_tokens; device_set_linux_md_component_holder (device, device->priv->holders_objpath->pdata[0]); state_tokens = NULL; holder = daemon_local_find_by_object_path (device->priv->daemon, device->priv->holders_objpath->pdata[0]); if (holder != NULL && holder->priv->device_is_linux_md) { gchar *dev_name; gchar *md_dev_path; gchar *state_contents; gchar *slot_contents; gint slot_number; gchar *endp; dev_name = g_path_get_basename (device->priv->native_path); md_dev_path = g_strdup_printf ("%s/md/dev-%s", holder->priv->native_path, dev_name); state_contents = sysfs_get_string (md_dev_path, "state"); g_strstrip (state_contents); state_tokens = g_strsplit (state_contents, ",", 0); slot_contents = sysfs_get_string (md_dev_path, "slot"); g_strstrip (slot_contents); slot_number = strtol (slot_contents, &endp, 0); if (endp != NULL && *endp == '\0') { md_comp_position = slot_number; } g_free (slot_contents); g_free (state_contents); g_free (md_dev_path); g_free (dev_name); } device_set_linux_md_component_state (device, state_tokens); g_strfreev (state_tokens); } else { /* no holder, nullify properties */ device_set_linux_md_component_holder (device, NULL); device_set_linux_md_component_state (device, NULL); } md_comp_level = g_udev_device_get_property (device->priv->d, "MD_LEVEL"); md_comp_num_raid_devices = g_udev_device_get_property_as_int (device->priv->d, "MD_DEVICES"); md_comp_uuid = g_udev_device_get_property (device->priv->d, "MD_UUID"); md_name = g_strdup (g_udev_device_get_property (device->priv->d, "MD_NAME")); s = NULL; if (md_name != NULL) s = strstr (md_name, ":"); if (s != NULL) { *s = '\0'; md_comp_home_host = md_name; md_comp_name = s + 1; } else { md_comp_home_host = ""; md_comp_name = md_name; } md_comp_version = device->priv->id_version; device_set_linux_md_component_level (device, md_comp_level); device_set_linux_md_component_position (device, md_comp_position); device_set_linux_md_component_num_raid_devices (device, md_comp_num_raid_devices); device_set_linux_md_component_uuid (device, md_comp_uuid); device_set_linux_md_component_home_host (device, md_comp_home_host); device_set_linux_md_component_name (device, md_comp_name); device_set_linux_md_component_version (device, md_comp_version); g_free (md_name); } else { device_set_device_is_linux_md_component (device, FALSE); device_set_linux_md_component_level (device, NULL); device_set_linux_md_component_position (device, -1); device_set_linux_md_component_num_raid_devices (device, 0); device_set_linux_md_component_uuid (device, NULL); device_set_linux_md_component_home_host (device, NULL); device_set_linux_md_component_name (device, NULL); device_set_linux_md_component_version (device, NULL); device_set_linux_md_component_holder (device, NULL); device_set_linux_md_component_state (device, NULL); } return TRUE; }
+Info
0
update_info_linux_md_component (Device *device) { if (g_strcmp0 (device->priv->id_type, "linux_raid_member") == 0) { const gchar *md_comp_level; gint md_comp_num_raid_devices; const gchar *md_comp_uuid; const gchar *md_comp_home_host; const gchar *md_comp_name; const gchar *md_comp_version; gchar *md_name; gchar *s; int md_comp_position; md_comp_position = -1; device_set_device_is_linux_md_component (device, TRUE); /* linux_md_component_holder and linux_md_component_state */ if (device->priv->holders_objpath->len == 1) { Device *holder; gchar **state_tokens; device_set_linux_md_component_holder (device, device->priv->holders_objpath->pdata[0]); state_tokens = NULL; holder = daemon_local_find_by_object_path (device->priv->daemon, device->priv->holders_objpath->pdata[0]); if (holder != NULL && holder->priv->device_is_linux_md) { gchar *dev_name; gchar *md_dev_path; gchar *state_contents; gchar *slot_contents; gint slot_number; gchar *endp; dev_name = g_path_get_basename (device->priv->native_path); md_dev_path = g_strdup_printf ("%s/md/dev-%s", holder->priv->native_path, dev_name); state_contents = sysfs_get_string (md_dev_path, "state"); g_strstrip (state_contents); state_tokens = g_strsplit (state_contents, ",", 0); slot_contents = sysfs_get_string (md_dev_path, "slot"); g_strstrip (slot_contents); slot_number = strtol (slot_contents, &endp, 0); if (endp != NULL && *endp == '\0') { md_comp_position = slot_number; } g_free (slot_contents); g_free (state_contents); g_free (md_dev_path); g_free (dev_name); } device_set_linux_md_component_state (device, state_tokens); g_strfreev (state_tokens); } else { /* no holder, nullify properties */ device_set_linux_md_component_holder (device, NULL); device_set_linux_md_component_state (device, NULL); } md_comp_level = g_udev_device_get_property (device->priv->d, "MD_LEVEL"); md_comp_num_raid_devices = g_udev_device_get_property_as_int (device->priv->d, "MD_DEVICES"); md_comp_uuid = g_udev_device_get_property (device->priv->d, "MD_UUID"); md_name = g_strdup (g_udev_device_get_property (device->priv->d, "MD_NAME")); s = NULL; if (md_name != NULL) s = strstr (md_name, ":"); if (s != NULL) { *s = '\0'; md_comp_home_host = md_name; md_comp_name = s + 1; } else { md_comp_home_host = ""; md_comp_name = md_name; } md_comp_version = device->priv->id_version; device_set_linux_md_component_level (device, md_comp_level); device_set_linux_md_component_position (device, md_comp_position); device_set_linux_md_component_num_raid_devices (device, md_comp_num_raid_devices); device_set_linux_md_component_uuid (device, md_comp_uuid); device_set_linux_md_component_home_host (device, md_comp_home_host); device_set_linux_md_component_name (device, md_comp_name); device_set_linux_md_component_version (device, md_comp_version); g_free (md_name); } else { device_set_device_is_linux_md_component (device, FALSE); device_set_linux_md_component_level (device, NULL); device_set_linux_md_component_position (device, -1); device_set_linux_md_component_num_raid_devices (device, 0); device_set_linux_md_component_uuid (device, NULL); device_set_linux_md_component_home_host (device, NULL); device_set_linux_md_component_name (device, NULL); device_set_linux_md_component_version (device, NULL); device_set_linux_md_component_holder (device, NULL); device_set_linux_md_component_state (device, NULL); } return TRUE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,447
update_info_luks (Device *device) { if (g_strcmp0 (device->priv->id_type, "crypto_LUKS") == 0 && device->priv->holders_objpath->len == 1) { device_set_device_is_luks (device, TRUE); device_set_luks_holder (device, device->priv->holders_objpath->pdata[0]); } else { device_set_device_is_luks (device, FALSE); device_set_luks_holder (device, NULL); } return TRUE; }
+Info
0
update_info_luks (Device *device) { if (g_strcmp0 (device->priv->id_type, "crypto_LUKS") == 0 && device->priv->holders_objpath->len == 1) { device_set_device_is_luks (device, TRUE); device_set_luks_holder (device, device->priv->holders_objpath->pdata[0]); } else { device_set_device_is_luks (device, FALSE); device_set_luks_holder (device, NULL); } return TRUE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,448
update_info_luks_cleartext (Device *device) { uid_t unlocked_by_uid; const gchar *dkd_dm_name; const gchar *dkd_dm_target_types; gboolean ret; ret = FALSE; dkd_dm_name = g_udev_device_get_property (device->priv->d, "DM_NAME"); dkd_dm_target_types = g_udev_device_get_property (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); if (dkd_dm_name != NULL && g_strcmp0 (dkd_dm_target_types, "crypt") == 0 && device->priv->slaves_objpath->len == 1) { /* TODO: might be racing with setting is_drive earlier */ device_set_device_is_drive (device, FALSE); if (g_str_has_prefix (dkd_dm_name, "temporary-cryptsetup-")) { /* ignore temporary devices created by /sbin/cryptsetup */ goto out; } device_set_device_is_luks_cleartext (device, TRUE); device_set_luks_cleartext_slave (device, ((gchar **) device->priv->slaves_objpath->pdata)[0]); if (luks_get_uid_from_dm_name (dkd_dm_name, &unlocked_by_uid)) { device_set_luks_cleartext_unlocked_by_uid (device, unlocked_by_uid); } /* TODO: export this at some point */ device_set_dm_name (device, dkd_dm_name); } else { device_set_device_is_luks_cleartext (device, FALSE); device_set_luks_cleartext_slave (device, NULL); } ret = TRUE; out: return ret; }
+Info
0
update_info_luks_cleartext (Device *device) { uid_t unlocked_by_uid; const gchar *dkd_dm_name; const gchar *dkd_dm_target_types; gboolean ret; ret = FALSE; dkd_dm_name = g_udev_device_get_property (device->priv->d, "DM_NAME"); dkd_dm_target_types = g_udev_device_get_property (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); if (dkd_dm_name != NULL && g_strcmp0 (dkd_dm_target_types, "crypt") == 0 && device->priv->slaves_objpath->len == 1) { /* TODO: might be racing with setting is_drive earlier */ device_set_device_is_drive (device, FALSE); if (g_str_has_prefix (dkd_dm_name, "temporary-cryptsetup-")) { /* ignore temporary devices created by /sbin/cryptsetup */ goto out; } device_set_device_is_luks_cleartext (device, TRUE); device_set_luks_cleartext_slave (device, ((gchar **) device->priv->slaves_objpath->pdata)[0]); if (luks_get_uid_from_dm_name (dkd_dm_name, &unlocked_by_uid)) { device_set_luks_cleartext_unlocked_by_uid (device, unlocked_by_uid); } /* TODO: export this at some point */ device_set_dm_name (device, dkd_dm_name); } else { device_set_device_is_luks_cleartext (device, FALSE); device_set_luks_cleartext_slave (device, NULL); } ret = TRUE; out: return ret; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,449
update_info_media_detection (Device *device) { gboolean detected; gboolean polling; gboolean inhibitable; gboolean inhibited; detected = FALSE; polling = FALSE; inhibitable = FALSE; inhibited = FALSE; if (device->priv->device_is_removable) { guint64 evt_media_change; GUdevDevice *parent; evt_media_change = sysfs_get_uint64 (device->priv->native_path, "../../evt_media_change"); if (evt_media_change & 1) { /* SATA AN capabable drive */ polling = FALSE; detected = TRUE; goto determined; } parent = g_udev_device_get_parent_with_subsystem (device->priv->d, "platform", NULL); if (parent != NULL) { /* never poll PC floppy drives, they are noisy (fdo #22149) */ if (g_str_has_prefix (g_udev_device_get_name (parent), "floppy.")) { g_object_unref (parent); goto determined; } g_object_unref (parent); } /* assume the device needs polling */ polling = TRUE; inhibitable = TRUE; /* custom udev rules might want to disable polling for known-broken * devices (fdo #26508) */ if (g_udev_device_has_property (device->priv->d, "UDISKS_DISABLE_POLLING") && g_udev_device_get_property_as_boolean (device->priv->d, "UDISKS_DISABLE_POLLING")) polling = FALSE; if (device->priv->polling_inhibitors != NULL || daemon_local_has_polling_inhibitors (device->priv->daemon)) { detected = FALSE; inhibited = TRUE; } else { detected = TRUE; inhibited = FALSE; } } determined: device_set_device_is_media_change_detected (device, detected); device_set_device_is_media_change_detection_polling (device, polling); device_set_device_is_media_change_detection_inhibitable (device, inhibitable); device_set_device_is_media_change_detection_inhibited (device, inhibited); return TRUE; }
+Info
0
update_info_media_detection (Device *device) { gboolean detected; gboolean polling; gboolean inhibitable; gboolean inhibited; detected = FALSE; polling = FALSE; inhibitable = FALSE; inhibited = FALSE; if (device->priv->device_is_removable) { guint64 evt_media_change; GUdevDevice *parent; evt_media_change = sysfs_get_uint64 (device->priv->native_path, "../../evt_media_change"); if (evt_media_change & 1) { /* SATA AN capabable drive */ polling = FALSE; detected = TRUE; goto determined; } parent = g_udev_device_get_parent_with_subsystem (device->priv->d, "platform", NULL); if (parent != NULL) { /* never poll PC floppy drives, they are noisy (fdo #22149) */ if (g_str_has_prefix (g_udev_device_get_name (parent), "floppy.")) { g_object_unref (parent); goto determined; } g_object_unref (parent); } /* assume the device needs polling */ polling = TRUE; inhibitable = TRUE; /* custom udev rules might want to disable polling for known-broken * devices (fdo #26508) */ if (g_udev_device_has_property (device->priv->d, "UDISKS_DISABLE_POLLING") && g_udev_device_get_property_as_boolean (device->priv->d, "UDISKS_DISABLE_POLLING")) polling = FALSE; if (device->priv->polling_inhibitors != NULL || daemon_local_has_polling_inhibitors (device->priv->daemon)) { detected = FALSE; inhibited = TRUE; } else { detected = TRUE; inhibited = FALSE; } } determined: device_set_device_is_media_change_detected (device, detected); device_set_device_is_media_change_detection_polling (device, polling); device_set_device_is_media_change_detection_inhibitable (device, inhibitable); device_set_device_is_media_change_detection_inhibited (device, inhibited); return TRUE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,450
update_info_mount_state (Device *device) { MountMonitor *monitor; GList *mounts; gboolean was_mounted; mounts = NULL; /* defer setting the mount point until FilesystemMount returns and * the mounts file is written */ if (device->priv->job_in_progress && g_strcmp0 (device->priv->job_id, "FilesystemMount") == 0) goto out; monitor = daemon_local_get_mount_monitor (device->priv->daemon); mounts = mount_monitor_get_mounts_for_dev (monitor, device->priv->dev); was_mounted = device->priv->device_is_mounted; if (mounts != NULL) { GList *l; guint n; gchar **mount_paths; mount_paths = g_new0 (gchar *, g_list_length (mounts) + 1); for (l = mounts, n = 0; l != NULL; l = l->next, n++) { mount_paths[n] = g_strdup (mount_get_mount_path (MOUNT (l->data))); } device_set_device_is_mounted (device, TRUE); device_set_device_mount_paths (device, mount_paths); if (!was_mounted) { uid_t mounted_by_uid; if (!mount_file_has_device (device->priv->device_file, &mounted_by_uid, NULL)) mounted_by_uid = 0; device_set_device_mounted_by_uid (device, mounted_by_uid); } g_strfreev (mount_paths); } else { gboolean remove_dir_on_unmount; gchar *old_mount_path; old_mount_path = NULL; if (device->priv->device_mount_paths->len > 0) old_mount_path = g_strdup (((gchar **) device->priv->device_mount_paths->pdata)[0]); device_set_device_is_mounted (device, FALSE); device_set_device_mount_paths (device, NULL); device_set_device_mounted_by_uid (device, 0); /* clean up stale mount directory */ remove_dir_on_unmount = FALSE; if (was_mounted && mount_file_has_device (device->priv->device_file, NULL, &remove_dir_on_unmount)) { mount_file_remove (device->priv->device_file, old_mount_path); if (remove_dir_on_unmount) { if (g_rmdir (old_mount_path) != 0) { g_warning ("Error removing dir '%s' on unmount: %m", old_mount_path); } } } g_free (old_mount_path); } out: g_list_foreach (mounts, (GFunc) g_object_unref, NULL); g_list_free (mounts); return TRUE; }
+Info
0
update_info_mount_state (Device *device) { MountMonitor *monitor; GList *mounts; gboolean was_mounted; mounts = NULL; /* defer setting the mount point until FilesystemMount returns and * the mounts file is written */ if (device->priv->job_in_progress && g_strcmp0 (device->priv->job_id, "FilesystemMount") == 0) goto out; monitor = daemon_local_get_mount_monitor (device->priv->daemon); mounts = mount_monitor_get_mounts_for_dev (monitor, device->priv->dev); was_mounted = device->priv->device_is_mounted; if (mounts != NULL) { GList *l; guint n; gchar **mount_paths; mount_paths = g_new0 (gchar *, g_list_length (mounts) + 1); for (l = mounts, n = 0; l != NULL; l = l->next, n++) { mount_paths[n] = g_strdup (mount_get_mount_path (MOUNT (l->data))); } device_set_device_is_mounted (device, TRUE); device_set_device_mount_paths (device, mount_paths); if (!was_mounted) { uid_t mounted_by_uid; if (!mount_file_has_device (device->priv->device_file, &mounted_by_uid, NULL)) mounted_by_uid = 0; device_set_device_mounted_by_uid (device, mounted_by_uid); } g_strfreev (mount_paths); } else { gboolean remove_dir_on_unmount; gchar *old_mount_path; old_mount_path = NULL; if (device->priv->device_mount_paths->len > 0) old_mount_path = g_strdup (((gchar **) device->priv->device_mount_paths->pdata)[0]); device_set_device_is_mounted (device, FALSE); device_set_device_mount_paths (device, NULL); device_set_device_mounted_by_uid (device, 0); /* clean up stale mount directory */ remove_dir_on_unmount = FALSE; if (was_mounted && mount_file_has_device (device->priv->device_file, NULL, &remove_dir_on_unmount)) { mount_file_remove (device->priv->device_file, old_mount_path); if (remove_dir_on_unmount) { if (g_rmdir (old_mount_path) != 0) { g_warning ("Error removing dir '%s' on unmount: %m", old_mount_path); } } } g_free (old_mount_path); } out: g_list_foreach (mounts, (GFunc) g_object_unref, NULL); g_list_free (mounts); return TRUE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,451
update_info_optical_disc (Device *device) { const gchar *cdrom_disc_state; gint cdrom_track_count; gint cdrom_track_count_audio; gint cdrom_session_count; /* device_is_optical_disc and optical_disc_* */ if (g_udev_device_has_property (device->priv->d, "ID_CDROM_MEDIA")) { device_set_device_is_optical_disc (device, TRUE); cdrom_track_count = 0; cdrom_track_count_audio = 0; cdrom_session_count = 0; if (g_udev_device_has_property (device->priv->d, "ID_CDROM_MEDIA_TRACK_COUNT")) cdrom_track_count = g_udev_device_get_property_as_int (device->priv->d, "ID_CDROM_MEDIA_TRACK_COUNT"); if (g_udev_device_has_property (device->priv->d, "ID_CDROM_MEDIA_TRACK_COUNT_AUDIO")) cdrom_track_count_audio = g_udev_device_get_property_as_int (device->priv->d, "ID_CDROM_MEDIA_TRACK_COUNT_AUDIO"); if (g_udev_device_has_property (device->priv->d, "ID_CDROM_MEDIA_SESSION_COUNT")) cdrom_session_count = g_udev_device_get_property_as_int (device->priv->d, "ID_CDROM_MEDIA_SESSION_COUNT"); device_set_optical_disc_num_tracks (device, cdrom_track_count); device_set_optical_disc_num_audio_tracks (device, cdrom_track_count_audio); device_set_optical_disc_num_sessions (device, cdrom_session_count); cdrom_disc_state = g_udev_device_get_property (device->priv->d, "ID_CDROM_MEDIA_STATE"); device_set_optical_disc_is_blank (device, g_strcmp0 (cdrom_disc_state, "blank") == 0); device_set_optical_disc_is_appendable (device, g_strcmp0 (cdrom_disc_state, "appendable") == 0); device_set_optical_disc_is_closed (device, g_strcmp0 (cdrom_disc_state, "complete") == 0); } else { device_set_device_is_optical_disc (device, FALSE); device_set_optical_disc_num_tracks (device, 0); device_set_optical_disc_num_audio_tracks (device, 0); device_set_optical_disc_num_sessions (device, 0); device_set_optical_disc_is_blank (device, FALSE); device_set_optical_disc_is_appendable (device, FALSE); device_set_optical_disc_is_closed (device, FALSE); } return TRUE; }
+Info
0
update_info_optical_disc (Device *device) { const gchar *cdrom_disc_state; gint cdrom_track_count; gint cdrom_track_count_audio; gint cdrom_session_count; /* device_is_optical_disc and optical_disc_* */ if (g_udev_device_has_property (device->priv->d, "ID_CDROM_MEDIA")) { device_set_device_is_optical_disc (device, TRUE); cdrom_track_count = 0; cdrom_track_count_audio = 0; cdrom_session_count = 0; if (g_udev_device_has_property (device->priv->d, "ID_CDROM_MEDIA_TRACK_COUNT")) cdrom_track_count = g_udev_device_get_property_as_int (device->priv->d, "ID_CDROM_MEDIA_TRACK_COUNT"); if (g_udev_device_has_property (device->priv->d, "ID_CDROM_MEDIA_TRACK_COUNT_AUDIO")) cdrom_track_count_audio = g_udev_device_get_property_as_int (device->priv->d, "ID_CDROM_MEDIA_TRACK_COUNT_AUDIO"); if (g_udev_device_has_property (device->priv->d, "ID_CDROM_MEDIA_SESSION_COUNT")) cdrom_session_count = g_udev_device_get_property_as_int (device->priv->d, "ID_CDROM_MEDIA_SESSION_COUNT"); device_set_optical_disc_num_tracks (device, cdrom_track_count); device_set_optical_disc_num_audio_tracks (device, cdrom_track_count_audio); device_set_optical_disc_num_sessions (device, cdrom_session_count); cdrom_disc_state = g_udev_device_get_property (device->priv->d, "ID_CDROM_MEDIA_STATE"); device_set_optical_disc_is_blank (device, g_strcmp0 (cdrom_disc_state, "blank") == 0); device_set_optical_disc_is_appendable (device, g_strcmp0 (cdrom_disc_state, "appendable") == 0); device_set_optical_disc_is_closed (device, g_strcmp0 (cdrom_disc_state, "complete") == 0); } else { device_set_device_is_optical_disc (device, FALSE); device_set_optical_disc_num_tracks (device, 0); device_set_optical_disc_num_audio_tracks (device, 0); device_set_optical_disc_num_sessions (device, 0); device_set_optical_disc_is_blank (device, FALSE); device_set_optical_disc_is_appendable (device, FALSE); device_set_optical_disc_is_closed (device, FALSE); } return TRUE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,452
update_info_partition (Device *device) { gboolean is_partition; is_partition = FALSE; /* Check if udisks-part-id identified the device as a partition.. this includes * identifying partitions set up by kpartx for multipath */ if (g_udev_device_has_property (device->priv->d, "UDISKS_PARTITION")) { guint64 size; const gchar *scheme; const gchar *type; const gchar *label; const gchar *uuid; const gchar* const *flags; guint64 offset; guint64 alignment_offset; const gchar *slave_sysfs_path; gint number; scheme = g_udev_device_get_property (device->priv->d, "UDISKS_PARTITION_SCHEME"); size = g_udev_device_get_property_as_uint64 (device->priv->d, "UDISKS_PARTITION_SIZE"); type = g_udev_device_get_property (device->priv->d, "UDISKS_PARTITION_TYPE"); label = g_udev_device_get_property (device->priv->d, "UDISKS_PARTITION_LABEL"); uuid = g_udev_device_get_property (device->priv->d, "UDISKS_PARTITION_UUID"); flags = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_PARTITION_FLAGS"); offset = g_udev_device_get_property_as_uint64 (device->priv->d, "UDISKS_PARTITION_OFFSET"); alignment_offset = g_udev_device_get_property_as_uint64 (device->priv->d, "UDISKS_PARTITION_ALIGNMENT_OFFSET"); number = g_udev_device_get_property_as_int (device->priv->d, "UDISKS_PARTITION_NUMBER"); slave_sysfs_path = g_udev_device_get_property (device->priv->d, "UDISKS_PARTITION_SLAVE"); if (slave_sysfs_path != NULL && scheme != NULL && number > 0) { gchar *s; device_set_partition_scheme (device, scheme); device_set_partition_size (device, size); device_set_partition_type (device, type); device_set_partition_label (device, label); device_set_partition_uuid (device, uuid); device_set_partition_flags (device, (gchar **) flags); device_set_partition_offset (device, offset); device_set_partition_alignment_offset (device, alignment_offset); device_set_partition_number (device, number); s = compute_object_path (slave_sysfs_path); device_set_partition_slave (device, s); g_free (s); is_partition = TRUE; } } /* Also handle the case where we are partitioned by the kernel and don't have * any UDISKS_PARTITION_* properties. * * This works without any udev UDISKS_PARTITION_* properties and is * there for maximum compatibility since udisks-part-id only knows a * limited set of partition table formats. */ if (!is_partition && sysfs_file_exists (device->priv->native_path, "start")) { guint64 start; guint64 size; guint64 offset; guint64 alignment_offset; gchar *s; guint n; device_set_device_is_partition (device, TRUE); start = sysfs_get_uint64 (device->priv->native_path, "start"); size = sysfs_get_uint64 (device->priv->native_path, "size"); alignment_offset = sysfs_get_uint64 (device->priv->native_path, "alignment_offset"); device_set_partition_size (device, size * 512); /* device->priv->device_block_size; */ device_set_partition_alignment_offset (device, alignment_offset); offset = sysfs_get_uint64 (device->priv->native_path, "start") * device->priv->device_block_size; device_set_partition_offset (device, offset); s = device->priv->native_path; for (n = strlen (s) - 1; n >= 0 && g_ascii_isdigit (s[n]); n--) ; device_set_partition_number (device, strtol (s + n + 1, NULL, 0)); s = g_strdup (device->priv->native_path); for (n = strlen (s) - 1; n >= 0 && s[n] != '/'; n--) s[n] = '\0'; s[n] = '\0'; device_set_partition_slave (device, compute_object_path (s)); g_free (s); is_partition = TRUE; } device_set_device_is_partition (device, is_partition); if (!is_partition) { /* otherwise, clear all the data */ device_set_partition_scheme (device, NULL); device_set_partition_size (device, device->priv->device_size); device_set_partition_type (device, NULL); device_set_partition_label (device, NULL); device_set_partition_uuid (device, NULL); device_set_partition_flags (device, NULL); } else { device_set_device_is_drive (device, FALSE); } return TRUE; }
+Info
0
update_info_partition (Device *device) { gboolean is_partition; is_partition = FALSE; /* Check if udisks-part-id identified the device as a partition.. this includes * identifying partitions set up by kpartx for multipath */ if (g_udev_device_has_property (device->priv->d, "UDISKS_PARTITION")) { guint64 size; const gchar *scheme; const gchar *type; const gchar *label; const gchar *uuid; const gchar* const *flags; guint64 offset; guint64 alignment_offset; const gchar *slave_sysfs_path; gint number; scheme = g_udev_device_get_property (device->priv->d, "UDISKS_PARTITION_SCHEME"); size = g_udev_device_get_property_as_uint64 (device->priv->d, "UDISKS_PARTITION_SIZE"); type = g_udev_device_get_property (device->priv->d, "UDISKS_PARTITION_TYPE"); label = g_udev_device_get_property (device->priv->d, "UDISKS_PARTITION_LABEL"); uuid = g_udev_device_get_property (device->priv->d, "UDISKS_PARTITION_UUID"); flags = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_PARTITION_FLAGS"); offset = g_udev_device_get_property_as_uint64 (device->priv->d, "UDISKS_PARTITION_OFFSET"); alignment_offset = g_udev_device_get_property_as_uint64 (device->priv->d, "UDISKS_PARTITION_ALIGNMENT_OFFSET"); number = g_udev_device_get_property_as_int (device->priv->d, "UDISKS_PARTITION_NUMBER"); slave_sysfs_path = g_udev_device_get_property (device->priv->d, "UDISKS_PARTITION_SLAVE"); if (slave_sysfs_path != NULL && scheme != NULL && number > 0) { gchar *s; device_set_partition_scheme (device, scheme); device_set_partition_size (device, size); device_set_partition_type (device, type); device_set_partition_label (device, label); device_set_partition_uuid (device, uuid); device_set_partition_flags (device, (gchar **) flags); device_set_partition_offset (device, offset); device_set_partition_alignment_offset (device, alignment_offset); device_set_partition_number (device, number); s = compute_object_path (slave_sysfs_path); device_set_partition_slave (device, s); g_free (s); is_partition = TRUE; } } /* Also handle the case where we are partitioned by the kernel and don't have * any UDISKS_PARTITION_* properties. * * This works without any udev UDISKS_PARTITION_* properties and is * there for maximum compatibility since udisks-part-id only knows a * limited set of partition table formats. */ if (!is_partition && sysfs_file_exists (device->priv->native_path, "start")) { guint64 start; guint64 size; guint64 offset; guint64 alignment_offset; gchar *s; guint n; device_set_device_is_partition (device, TRUE); start = sysfs_get_uint64 (device->priv->native_path, "start"); size = sysfs_get_uint64 (device->priv->native_path, "size"); alignment_offset = sysfs_get_uint64 (device->priv->native_path, "alignment_offset"); device_set_partition_size (device, size * 512); /* device->priv->device_block_size; */ device_set_partition_alignment_offset (device, alignment_offset); offset = sysfs_get_uint64 (device->priv->native_path, "start") * device->priv->device_block_size; device_set_partition_offset (device, offset); s = device->priv->native_path; for (n = strlen (s) - 1; n >= 0 && g_ascii_isdigit (s[n]); n--) ; device_set_partition_number (device, strtol (s + n + 1, NULL, 0)); s = g_strdup (device->priv->native_path); for (n = strlen (s) - 1; n >= 0 && s[n] != '/'; n--) s[n] = '\0'; s[n] = '\0'; device_set_partition_slave (device, compute_object_path (s)); g_free (s); is_partition = TRUE; } device_set_device_is_partition (device, is_partition); if (!is_partition) { /* otherwise, clear all the data */ device_set_partition_scheme (device, NULL); device_set_partition_size (device, device->priv->device_size); device_set_partition_type (device, NULL); device_set_partition_label (device, NULL); device_set_partition_uuid (device, NULL); device_set_partition_flags (device, NULL); } else { device_set_device_is_drive (device, FALSE); } return TRUE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,453
update_info_partition_table (Device *device) { gboolean is_partition_table; is_partition_table = FALSE; /* Check if udisks-part-id identified the device as a partition table.. this includes * identifying partition tables set up by kpartx for multipath etc. */ if (g_udev_device_get_property_as_boolean (device->priv->d, "UDISKS_PARTITION_TABLE")) { device_set_partition_table_scheme (device, g_udev_device_get_property (device->priv->d, "UDISKS_PARTITION_TABLE_SCHEME")); device_set_partition_table_count (device, g_udev_device_get_property_as_int (device->priv->d, "UDISKS_PARTITION_TABLE_COUNT")); is_partition_table = TRUE; } /* Note that udisks-part-id might not detect all partition table * formats.. so in the negative case, also double check with * information in sysfs. * * The kernel guarantees that all childs are created before the * uevent for the parent is created. So if we have childs, we must * be a partition table. * * To detect a child we check for the existance of a subdir that has * the parents name as a prefix (e.g. for parent sda then sda1, * sda2, sda3 ditto md0, md0p1 etc. etc. will work). */ if (!is_partition_table) { gchar *s; GDir *dir; s = g_path_get_basename (device->priv->native_path); if ((dir = g_dir_open (device->priv->native_path, 0, NULL)) != NULL) { guint partition_count; const gchar *name; partition_count = 0; while ((name = g_dir_read_name (dir)) != NULL) { if (g_str_has_prefix (name, s)) { partition_count++; } } g_dir_close (dir); if (partition_count > 0) { device_set_partition_table_scheme (device, ""); device_set_partition_table_count (device, partition_count); is_partition_table = TRUE; } } g_free (s); } device_set_device_is_partition_table (device, is_partition_table); if (!is_partition_table) { /* otherwise, clear all the data */ device_set_partition_table_scheme (device, NULL); device_set_partition_table_count (device, 0); } return TRUE; }
+Info
0
update_info_partition_table (Device *device) { gboolean is_partition_table; is_partition_table = FALSE; /* Check if udisks-part-id identified the device as a partition table.. this includes * identifying partition tables set up by kpartx for multipath etc. */ if (g_udev_device_get_property_as_boolean (device->priv->d, "UDISKS_PARTITION_TABLE")) { device_set_partition_table_scheme (device, g_udev_device_get_property (device->priv->d, "UDISKS_PARTITION_TABLE_SCHEME")); device_set_partition_table_count (device, g_udev_device_get_property_as_int (device->priv->d, "UDISKS_PARTITION_TABLE_COUNT")); is_partition_table = TRUE; } /* Note that udisks-part-id might not detect all partition table * formats.. so in the negative case, also double check with * information in sysfs. * * The kernel guarantees that all childs are created before the * uevent for the parent is created. So if we have childs, we must * be a partition table. * * To detect a child we check for the existance of a subdir that has * the parents name as a prefix (e.g. for parent sda then sda1, * sda2, sda3 ditto md0, md0p1 etc. etc. will work). */ if (!is_partition_table) { gchar *s; GDir *dir; s = g_path_get_basename (device->priv->native_path); if ((dir = g_dir_open (device->priv->native_path, 0, NULL)) != NULL) { guint partition_count; const gchar *name; partition_count = 0; while ((name = g_dir_read_name (dir)) != NULL) { if (g_str_has_prefix (name, s)) { partition_count++; } } g_dir_close (dir); if (partition_count > 0) { device_set_partition_table_scheme (device, ""); device_set_partition_table_count (device, partition_count); is_partition_table = TRUE; } } g_free (s); } device_set_device_is_partition_table (device, is_partition_table); if (!is_partition_table) { /* otherwise, clear all the data */ device_set_partition_table_scheme (device, NULL); device_set_partition_table_count (device, 0); } return TRUE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,454
count_entries (PartitionTable *pt) { guint ret; guint num_top_level; guint n; ret = 0; num_top_level = part_table_get_num_entries (pt); for (n = 0; n < num_top_level; n++) { PartitionTable *nested; if (part_table_entry_is_in_use (pt, n)) ret++; nested = part_table_entry_get_nested (pt, n); if (nested != NULL) { ret += part_table_get_num_entries (nested); } } return ret; }
+Info
0
count_entries (PartitionTable *pt) { guint ret; guint num_top_level; guint n; ret = 0; num_top_level = part_table_get_num_entries (pt); for (n = 0; n < num_top_level; n++) { PartitionTable *nested; if (part_table_entry_is_in_use (pt, n)) ret++; nested = part_table_entry_get_nested (pt, n); if (nested != NULL) { ret += part_table_get_num_entries (nested); } } return ret; }
@@ -246,6 +246,8 @@ get_part_table_device_file (struct udev_device *given_device, //g_printerr ("targets_type=`%s'\n", targets_type); //g_printerr ("encoded_targets_params=`%s'\n", encoded_targets_params); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (g_strcmp0 (targets_type, "linear") == 0) { gint partition_slave_major;
CWE-200
null
null
9,455
get_udev_device_from_device_file (struct udev *udev, const gchar *device_file) { struct udev_device *device; struct stat statbuf; device = NULL; if (stat (device_file, &statbuf) != 0) { g_printerr ("Error statting %s: %m\n", device_file); goto out; } device = udev_device_new_from_devnum (udev, 'b', statbuf.st_rdev); if (device == NULL) { g_printerr ("Error getting udev device for %s: %m\n", device_file); goto out; } out: return device; }
+Info
0
get_udev_device_from_device_file (struct udev *udev, const gchar *device_file) { struct udev_device *device; struct stat statbuf; device = NULL; if (stat (device_file, &statbuf) != 0) { g_printerr ("Error statting %s: %m\n", device_file); goto out; } device = udev_device_new_from_devnum (udev, 'b', statbuf.st_rdev); if (device == NULL) { g_printerr ("Error getting udev device for %s: %m\n", device_file); goto out; } out: return device; }
@@ -246,6 +246,8 @@ get_part_table_device_file (struct udev_device *given_device, //g_printerr ("targets_type=`%s'\n", targets_type); //g_printerr ("encoded_targets_params=`%s'\n", encoded_targets_params); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (g_strcmp0 (targets_type, "linear") == 0) { gint partition_slave_major;
CWE-200
null
null
9,456
usage (int argc, char *argv[]) { execlp ("man", "man", "part_id", NULL); g_printerr ("Cannot show man page: %m\n"); exit (1); }
+Info
0
usage (int argc, char *argv[]) { execlp ("man", "man", "part_id", NULL); g_printerr ("Cannot show man page: %m\n"); exit (1); }
@@ -246,6 +246,8 @@ get_part_table_device_file (struct udev_device *given_device, //g_printerr ("targets_type=`%s'\n", targets_type); //g_printerr ("encoded_targets_params=`%s'\n", encoded_targets_params); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (g_strcmp0 (targets_type, "linear") == 0) { gint partition_slave_major;
CWE-200
null
null
9,457
_udev_util_encode_string(const char *str, char *str_enc, size_t len) { size_t i, j; if (str == NULL || str_enc == NULL) return -1; for (i = 0, j = 0; str[i] != '\0'; i++) { int seqlen; seqlen = utf8_encoded_valid_unichar(&str[i]); if (seqlen > 1) { if (len-j < (size_t)seqlen) goto err; memcpy(&str_enc[j], &str[i], seqlen); j += seqlen; i += (seqlen-1); } else if (str[i] == '\\' || !is_whitelisted(str[i], NULL)) { if (len-j < 4) goto err; sprintf(&str_enc[j], "\\x%02x", (unsigned char) str[i]); j += 4; } else { if (len-j < 1) goto err; str_enc[j] = str[i]; j++; } } if (len-j < 1) goto err; str_enc[j] = '\0'; return 0; err: return -1; }
+Info
0
_udev_util_encode_string(const char *str, char *str_enc, size_t len) { size_t i, j; if (str == NULL || str_enc == NULL) return -1; for (i = 0, j = 0; str[i] != '\0'; i++) { int seqlen; seqlen = utf8_encoded_valid_unichar(&str[i]); if (seqlen > 1) { if (len-j < (size_t)seqlen) goto err; memcpy(&str_enc[j], &str[i], seqlen); j += seqlen; i += (seqlen-1); } else if (str[i] == '\\' || !is_whitelisted(str[i], NULL)) { if (len-j < 4) goto err; sprintf(&str_enc[j], "\\x%02x", (unsigned char) str[i]); j += 4; } else { if (len-j < 1) goto err; str_enc[j] = str[i]; j++; } } if (len-j < 1) goto err; str_enc[j] = '\0'; return 0; err: return -1; }
@@ -287,7 +287,10 @@ dm_export (int major, int minor) g_string_append (target_types_str, target_type); g_string_append_printf (start_str, "%" G_GUINT64_FORMAT, start); g_string_append_printf (length_str, "%" G_GUINT64_FORMAT, length); - if (params != NULL && strlen (params) > 0) + /* Set target_params for known-safe and known-needed target types only. In particular, + * we must not export it for "crypto", since that would expose + * information about the key. */ + if (g_strcmp0 (target_type, "linear") == 0 && params != NULL && strlen (params) > 0) { _udev_util_encode_string (params, buf, sizeof (buf)); g_string_append (params_str, buf);
CWE-200
null
null
9,458
static int count_args(const char **argv) { int i = 0; if (argv) { while (argv[i] != NULL) i++; } return i; }
Bypass
0
static int count_args(const char **argv) { int i = 0; if (argv) { while (argv[i] != NULL) i++; } return i; }
@@ -1313,6 +1313,7 @@ int parse_arguments(int *argc_p, const char ***argv_p) const char *arg, **argv = *argv_p; int argc = *argc_p; int opt; + int orig_protect_args = protect_args; if (ref && *ref) set_refuse_options(ref); @@ -1934,6 +1935,10 @@ int parse_arguments(int *argc_p, const char ***argv_p) if (fuzzy_basis > 1) fuzzy_basis = basis_dir_cnt + 1; + /* Don't let the client reset protect_args if it was already processed */ + if (orig_protect_args == 2 && am_server) + protect_args = orig_protect_args; + if (protect_args == 1 && am_server) return 1;
null
null
null
9,459
void limit_output_verbosity(int level) { short info_limits[COUNT_INFO], debug_limits[COUNT_DEBUG]; int j; if (level > MAX_VERBOSITY) return; memset(info_limits, 0, sizeof info_limits); memset(debug_limits, 0, sizeof debug_limits); /* Compute the level limits in the above arrays. */ for (j = 1; j <= level; j++) { parse_output_words(info_words, info_limits, info_verbosity[j], LIMIT_PRIORITY); parse_output_words(debug_words, debug_limits, debug_verbosity[j], LIMIT_PRIORITY); } for (j = 0; j < COUNT_INFO; j++) { if (info_levels[j] > info_limits[j]) info_levels[j] = info_limits[j]; } for (j = 0; j < COUNT_DEBUG; j++) { if (debug_levels[j] > debug_limits[j]) debug_levels[j] = debug_limits[j]; } }
Bypass
0
void limit_output_verbosity(int level) { short info_limits[COUNT_INFO], debug_limits[COUNT_DEBUG]; int j; if (level > MAX_VERBOSITY) return; memset(info_limits, 0, sizeof info_limits); memset(debug_limits, 0, sizeof debug_limits); /* Compute the level limits in the above arrays. */ for (j = 1; j <= level; j++) { parse_output_words(info_words, info_limits, info_verbosity[j], LIMIT_PRIORITY); parse_output_words(debug_words, debug_limits, debug_verbosity[j], LIMIT_PRIORITY); } for (j = 0; j < COUNT_INFO; j++) { if (info_levels[j] > info_limits[j]) info_levels[j] = info_limits[j]; } for (j = 0; j < COUNT_DEBUG; j++) { if (debug_levels[j] > debug_limits[j]) debug_levels[j] = debug_limits[j]; } }
@@ -1313,6 +1313,7 @@ int parse_arguments(int *argc_p, const char ***argv_p) const char *arg, **argv = *argv_p; int argc = *argc_p; int opt; + int orig_protect_args = protect_args; if (ref && *ref) set_refuse_options(ref); @@ -1934,6 +1935,10 @@ int parse_arguments(int *argc_p, const char ***argv_p) if (fuzzy_basis > 1) fuzzy_basis = basis_dir_cnt + 1; + /* Don't let the client reset protect_args if it was already processed */ + if (orig_protect_args == 2 && am_server) + protect_args = orig_protect_args; + if (protect_args == 1 && am_server) return 1;
null
null
null
9,460
static char *make_output_option(struct output_struct *words, short *levels, uchar where) { char *str = words == info_words ? "--info=" : "--debug="; int j, counts[MAX_OUT_LEVEL+1], pos, skipped = 0, len = 0, max = 0, lev = 0; int word_count = words == info_words ? COUNT_INFO : COUNT_DEBUG; char *buf; memset(counts, 0, sizeof counts); for (j = 0; words[j].name; j++) { if (words[j].flag != j) { rprintf(FERROR, "rsync: internal error on %s%s: %d != %d\n", words == info_words ? "INFO_" : "DEBUG_", words[j].name, words[j].flag, j); exit_cleanup(RERR_UNSUPPORTED); } if (!(words[j].where & where)) continue; if (words[j].priority == DEFAULT_PRIORITY) { /* Implied items don't need to be mentioned. */ skipped++; continue; } len += len ? 1 : strlen(str); len += strlen(words[j].name); len += levels[j] == 1 ? 0 : 1; if (words[j].priority == HELP_PRIORITY) continue; /* no abbreviating for help */ assert(levels[j] <= MAX_OUT_LEVEL); if (++counts[levels[j]] > max) { /* Determine which level has the most items. */ lev = levels[j]; max = counts[lev]; } } /* Sanity check the COUNT_* define against the length of the table. */ if (j != word_count) { rprintf(FERROR, "rsync: internal error: %s is wrong! (%d != %d)\n", words == info_words ? "COUNT_INFO" : "COUNT_DEBUG", j, word_count); exit_cleanup(RERR_UNSUPPORTED); } if (!len) return NULL; len++; if (!(buf = new_array(char, len))) out_of_memory("make_output_option"); pos = 0; if (skipped || max < 5) lev = -1; else { if (lev == 0) pos += snprintf(buf, len, "%sNONE", str); else if (lev == 1) pos += snprintf(buf, len, "%sALL", str); else pos += snprintf(buf, len, "%sALL%d", str, lev); } for (j = 0; words[j].name && pos < len; j++) { if (words[j].priority == DEFAULT_PRIORITY || levels[j] == lev || !(words[j].where & where)) continue; if (pos) buf[pos++] = ','; else pos += strlcpy(buf+pos, str, len-pos); if (pos < len) pos += strlcpy(buf+pos, words[j].name, len-pos); /* Level 1 is implied by the name alone. */ if (levels[j] != 1 && pos < len) buf[pos++] = '0' + levels[j]; } buf[pos] = '\0'; return buf; }
Bypass
0
static char *make_output_option(struct output_struct *words, short *levels, uchar where) { char *str = words == info_words ? "--info=" : "--debug="; int j, counts[MAX_OUT_LEVEL+1], pos, skipped = 0, len = 0, max = 0, lev = 0; int word_count = words == info_words ? COUNT_INFO : COUNT_DEBUG; char *buf; memset(counts, 0, sizeof counts); for (j = 0; words[j].name; j++) { if (words[j].flag != j) { rprintf(FERROR, "rsync: internal error on %s%s: %d != %d\n", words == info_words ? "INFO_" : "DEBUG_", words[j].name, words[j].flag, j); exit_cleanup(RERR_UNSUPPORTED); } if (!(words[j].where & where)) continue; if (words[j].priority == DEFAULT_PRIORITY) { /* Implied items don't need to be mentioned. */ skipped++; continue; } len += len ? 1 : strlen(str); len += strlen(words[j].name); len += levels[j] == 1 ? 0 : 1; if (words[j].priority == HELP_PRIORITY) continue; /* no abbreviating for help */ assert(levels[j] <= MAX_OUT_LEVEL); if (++counts[levels[j]] > max) { /* Determine which level has the most items. */ lev = levels[j]; max = counts[lev]; } } /* Sanity check the COUNT_* define against the length of the table. */ if (j != word_count) { rprintf(FERROR, "rsync: internal error: %s is wrong! (%d != %d)\n", words == info_words ? "COUNT_INFO" : "COUNT_DEBUG", j, word_count); exit_cleanup(RERR_UNSUPPORTED); } if (!len) return NULL; len++; if (!(buf = new_array(char, len))) out_of_memory("make_output_option"); pos = 0; if (skipped || max < 5) lev = -1; else { if (lev == 0) pos += snprintf(buf, len, "%sNONE", str); else if (lev == 1) pos += snprintf(buf, len, "%sALL", str); else pos += snprintf(buf, len, "%sALL%d", str, lev); } for (j = 0; words[j].name && pos < len; j++) { if (words[j].priority == DEFAULT_PRIORITY || levels[j] == lev || !(words[j].where & where)) continue; if (pos) buf[pos++] = ','; else pos += strlcpy(buf+pos, str, len-pos); if (pos < len) pos += strlcpy(buf+pos, words[j].name, len-pos); /* Level 1 is implied by the name alone. */ if (levels[j] != 1 && pos < len) buf[pos++] = '0' + levels[j]; } buf[pos] = '\0'; return buf; }
@@ -1313,6 +1313,7 @@ int parse_arguments(int *argc_p, const char ***argv_p) const char *arg, **argv = *argv_p; int argc = *argc_p; int opt; + int orig_protect_args = protect_args; if (ref && *ref) set_refuse_options(ref); @@ -1934,6 +1935,10 @@ int parse_arguments(int *argc_p, const char ***argv_p) if (fuzzy_basis > 1) fuzzy_basis = basis_dir_cnt + 1; + /* Don't let the client reset protect_args if it was already processed */ + if (orig_protect_args == 2 && am_server) + protect_args = orig_protect_args; + if (protect_args == 1 && am_server) return 1;
null
null
null
9,461
void option_error(void) { if (!err_buf[0]) { strlcpy(err_buf, "Error parsing options: option may " "be supported on client but not on server?\n", sizeof err_buf); } rprintf(FERROR, RSYNC_NAME ": %s", err_buf); msleep(20); }
Bypass
0
void option_error(void) { if (!err_buf[0]) { strlcpy(err_buf, "Error parsing options: option may " "be supported on client but not on server?\n", sizeof err_buf); } rprintf(FERROR, RSYNC_NAME ": %s", err_buf); msleep(20); }
@@ -1313,6 +1313,7 @@ int parse_arguments(int *argc_p, const char ***argv_p) const char *arg, **argv = *argv_p; int argc = *argc_p; int opt; + int orig_protect_args = protect_args; if (ref && *ref) set_refuse_options(ref); @@ -1934,6 +1935,10 @@ int parse_arguments(int *argc_p, const char ***argv_p) if (fuzzy_basis > 1) fuzzy_basis = basis_dir_cnt + 1; + /* Don't let the client reset protect_args if it was already processed */ + if (orig_protect_args == 2 && am_server) + protect_args = orig_protect_args; + if (protect_args == 1 && am_server) return 1;
null
null
null
9,462
static void output_item_help(struct output_struct *words) { short *levels = words == info_words ? info_levels : debug_levels; const char **verbosity = words == info_words ? info_verbosity : debug_verbosity; char buf[128], *opt, *fmt = "%-10s %s\n"; int j; reset_output_levels(); rprintf(FINFO, "Use OPT or OPT1 for level 1 output, OPT2 for level 2, etc.; OPT0 silences.\n"); rprintf(FINFO, "\n"); for (j = 0; words[j].name; j++) rprintf(FINFO, fmt, words[j].name, words[j].help); rprintf(FINFO, "\n"); snprintf(buf, sizeof buf, "Set all %s options (e.g. all%d)", words[j].help, MAX_OUT_LEVEL); rprintf(FINFO, fmt, "ALL", buf); snprintf(buf, sizeof buf, "Silence all %s options (same as all0)", words[j].help); rprintf(FINFO, fmt, "NONE", buf); rprintf(FINFO, fmt, "HELP", "Output this help message"); rprintf(FINFO, "\n"); rprintf(FINFO, "Options added for each increase in verbose level:\n"); for (j = 1; j <= MAX_VERBOSITY; j++) { parse_output_words(words, levels, verbosity[j], HELP_PRIORITY); opt = make_output_option(words, levels, W_CLI|W_SRV|W_SND|W_REC); if (opt) { rprintf(FINFO, "%d) %s\n", j, strchr(opt, '=')+1); free(opt); } reset_output_levels(); } }
Bypass
0
static void output_item_help(struct output_struct *words) { short *levels = words == info_words ? info_levels : debug_levels; const char **verbosity = words == info_words ? info_verbosity : debug_verbosity; char buf[128], *opt, *fmt = "%-10s %s\n"; int j; reset_output_levels(); rprintf(FINFO, "Use OPT or OPT1 for level 1 output, OPT2 for level 2, etc.; OPT0 silences.\n"); rprintf(FINFO, "\n"); for (j = 0; words[j].name; j++) rprintf(FINFO, fmt, words[j].name, words[j].help); rprintf(FINFO, "\n"); snprintf(buf, sizeof buf, "Set all %s options (e.g. all%d)", words[j].help, MAX_OUT_LEVEL); rprintf(FINFO, fmt, "ALL", buf); snprintf(buf, sizeof buf, "Silence all %s options (same as all0)", words[j].help); rprintf(FINFO, fmt, "NONE", buf); rprintf(FINFO, fmt, "HELP", "Output this help message"); rprintf(FINFO, "\n"); rprintf(FINFO, "Options added for each increase in verbose level:\n"); for (j = 1; j <= MAX_VERBOSITY; j++) { parse_output_words(words, levels, verbosity[j], HELP_PRIORITY); opt = make_output_option(words, levels, W_CLI|W_SRV|W_SND|W_REC); if (opt) { rprintf(FINFO, "%d) %s\n", j, strchr(opt, '=')+1); free(opt); } reset_output_levels(); } }
@@ -1313,6 +1313,7 @@ int parse_arguments(int *argc_p, const char ***argv_p) const char *arg, **argv = *argv_p; int argc = *argc_p; int opt; + int orig_protect_args = protect_args; if (ref && *ref) set_refuse_options(ref); @@ -1934,6 +1935,10 @@ int parse_arguments(int *argc_p, const char ***argv_p) if (fuzzy_basis > 1) fuzzy_basis = basis_dir_cnt + 1; + /* Don't let the client reset protect_args if it was already processed */ + if (orig_protect_args == 2 && am_server) + protect_args = orig_protect_args; + if (protect_args == 1 && am_server) return 1;
null
null
null
9,463
static char *parse_hostspec(char *str, char **path_start_ptr, int *port_ptr) { char *s, *host_start = str; int hostlen = 0, userlen = 0; char *ret; for (s = str; ; s++) { if (!*s) { /* It is only OK if we run out of string with rsync:// */ if (!port_ptr) return NULL; if (!hostlen) hostlen = s - host_start; break; } if (*s == ':' || *s == '/') { if (!hostlen) hostlen = s - host_start; if (*s++ == '/') { if (!port_ptr) return NULL; } else if (port_ptr) { *port_ptr = atoi(s); while (isDigit(s)) s++; if (*s && *s++ != '/') return NULL; } break; } if (*s == '@') { userlen = s - str + 1; host_start = s + 1; } else if (*s == '[') { if (s != host_start++) return NULL; while (*s && *s != ']' && *s != '/') s++; /*SHARED ITERATOR*/ hostlen = s - host_start; if (*s != ']' || (s[1] && s[1] != '/' && s[1] != ':') || !hostlen) return NULL; } } *path_start_ptr = s; ret = new_array(char, userlen + hostlen + 1); if (userlen) strlcpy(ret, str, userlen + 1); strlcpy(ret + userlen, host_start, hostlen + 1); return ret; }
Bypass
0
static char *parse_hostspec(char *str, char **path_start_ptr, int *port_ptr) { char *s, *host_start = str; int hostlen = 0, userlen = 0; char *ret; for (s = str; ; s++) { if (!*s) { /* It is only OK if we run out of string with rsync:// */ if (!port_ptr) return NULL; if (!hostlen) hostlen = s - host_start; break; } if (*s == ':' || *s == '/') { if (!hostlen) hostlen = s - host_start; if (*s++ == '/') { if (!port_ptr) return NULL; } else if (port_ptr) { *port_ptr = atoi(s); while (isDigit(s)) s++; if (*s && *s++ != '/') return NULL; } break; } if (*s == '@') { userlen = s - str + 1; host_start = s + 1; } else if (*s == '[') { if (s != host_start++) return NULL; while (*s && *s != ']' && *s != '/') s++; /*SHARED ITERATOR*/ hostlen = s - host_start; if (*s != ']' || (s[1] && s[1] != '/' && s[1] != ':') || !hostlen) return NULL; } } *path_start_ptr = s; ret = new_array(char, userlen + hostlen + 1); if (userlen) strlcpy(ret, str, userlen + 1); strlcpy(ret + userlen, host_start, hostlen + 1); return ret; }
@@ -1313,6 +1313,7 @@ int parse_arguments(int *argc_p, const char ***argv_p) const char *arg, **argv = *argv_p; int argc = *argc_p; int opt; + int orig_protect_args = protect_args; if (ref && *ref) set_refuse_options(ref); @@ -1934,6 +1935,10 @@ int parse_arguments(int *argc_p, const char ***argv_p) if (fuzzy_basis > 1) fuzzy_basis = basis_dir_cnt + 1; + /* Don't let the client reset protect_args if it was already processed */ + if (orig_protect_args == 2 && am_server) + protect_args = orig_protect_args; + if (protect_args == 1 && am_server) return 1;
null
null
null
9,464
static OFF_T parse_size_arg(char **size_arg, char def_suf) { int reps, mult, make_compatible = 0; const char *arg; OFF_T size = 1; for (arg = *size_arg; isDigit(arg); arg++) {} if (*arg == '.') for (arg++; isDigit(arg); arg++) {} switch (*arg && *arg != '+' && *arg != '-' ? *arg++ : def_suf) { case 'b': case 'B': reps = 0; break; case 'k': case 'K': reps = 1; break; case 'm': case 'M': reps = 2; break; case 'g': case 'G': reps = 3; break; default: return -1; } if (*arg == 'b' || *arg == 'B') mult = 1000, make_compatible = 1, arg++; else if (!*arg || *arg == '+' || *arg == '-') mult = 1024; else if (strncasecmp(arg, "ib", 2) == 0) mult = 1024, arg += 2; else return -1; while (reps--) size *= mult; size *= atof(*size_arg); if ((*arg == '+' || *arg == '-') && arg[1] == '1') size += atoi(arg), make_compatible = 1, arg += 2; if (*arg) return -1; if (size > 0 && make_compatible && def_suf == 'b') { /* We convert this manually because we may need %lld precision, * and that's not a portable sprintf() escape. */ char buf[128], *s = buf + sizeof buf - 1; OFF_T num = size; *s = '\0'; while (num) { *--s = (char)(num % 10) + '0'; num /= 10; } if (!(*size_arg = strdup(s))) out_of_memory("parse_size_arg"); } return size; }
Bypass
0
static OFF_T parse_size_arg(char **size_arg, char def_suf) { int reps, mult, make_compatible = 0; const char *arg; OFF_T size = 1; for (arg = *size_arg; isDigit(arg); arg++) {} if (*arg == '.') for (arg++; isDigit(arg); arg++) {} switch (*arg && *arg != '+' && *arg != '-' ? *arg++ : def_suf) { case 'b': case 'B': reps = 0; break; case 'k': case 'K': reps = 1; break; case 'm': case 'M': reps = 2; break; case 'g': case 'G': reps = 3; break; default: return -1; } if (*arg == 'b' || *arg == 'B') mult = 1000, make_compatible = 1, arg++; else if (!*arg || *arg == '+' || *arg == '-') mult = 1024; else if (strncasecmp(arg, "ib", 2) == 0) mult = 1024, arg += 2; else return -1; while (reps--) size *= mult; size *= atof(*size_arg); if ((*arg == '+' || *arg == '-') && arg[1] == '1') size += atoi(arg), make_compatible = 1, arg += 2; if (*arg) return -1; if (size > 0 && make_compatible && def_suf == 'b') { /* We convert this manually because we may need %lld precision, * and that's not a portable sprintf() escape. */ char buf[128], *s = buf + sizeof buf - 1; OFF_T num = size; *s = '\0'; while (num) { *--s = (char)(num % 10) + '0'; num /= 10; } if (!(*size_arg = strdup(s))) out_of_memory("parse_size_arg"); } return size; }
@@ -1313,6 +1313,7 @@ int parse_arguments(int *argc_p, const char ***argv_p) const char *arg, **argv = *argv_p; int argc = *argc_p; int opt; + int orig_protect_args = protect_args; if (ref && *ref) set_refuse_options(ref); @@ -1934,6 +1935,10 @@ int parse_arguments(int *argc_p, const char ***argv_p) if (fuzzy_basis > 1) fuzzy_basis = basis_dir_cnt + 1; + /* Don't let the client reset protect_args if it was already processed */ + if (orig_protect_args == 2 && am_server) + protect_args = orig_protect_args; + if (protect_args == 1 && am_server) return 1;
null
null
null
9,465
static void print_rsync_version(enum logcode f) { char *subprotocol = ""; char const *got_socketpair = "no "; char const *have_inplace = "no "; char const *hardlinks = "no "; char const *prealloc = "no "; char const *symtimes = "no "; char const *acls = "no "; char const *xattrs = "no "; char const *links = "no "; char const *iconv = "no "; char const *ipv6 = "no "; STRUCT_STAT *dumstat; #if SUBPROTOCOL_VERSION != 0 if (asprintf(&subprotocol, ".PR%d", SUBPROTOCOL_VERSION) < 0) out_of_memory("print_rsync_version"); #endif #ifdef HAVE_SOCKETPAIR got_socketpair = ""; #endif #ifdef HAVE_FTRUNCATE have_inplace = ""; #endif #ifdef SUPPORT_HARD_LINKS hardlinks = ""; #endif #ifdef SUPPORT_PREALLOCATION prealloc = ""; #endif #ifdef SUPPORT_ACLS acls = ""; #endif #ifdef SUPPORT_XATTRS xattrs = ""; #endif #ifdef SUPPORT_LINKS links = ""; #endif #ifdef INET6 ipv6 = ""; #endif #ifdef ICONV_OPTION iconv = ""; #endif #ifdef CAN_SET_SYMLINK_TIMES symtimes = ""; #endif rprintf(f, "%s version %s protocol version %d%s\n", RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION, subprotocol); rprintf(f, "Copyright (C) 1996-2015 by Andrew Tridgell, Wayne Davison, and others.\n"); rprintf(f, "Web site: http://rsync.samba.org/\n"); rprintf(f, "Capabilities:\n"); rprintf(f, " %d-bit files, %d-bit inums, %d-bit timestamps, %d-bit long ints,\n", (int)(sizeof (OFF_T) * 8), (int)(sizeof dumstat->st_ino * 8), /* Don't check ino_t! */ (int)(sizeof (time_t) * 8), (int)(sizeof (int64) * 8)); rprintf(f, " %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n", got_socketpair, hardlinks, links, ipv6, have_inplace); rprintf(f, " %sappend, %sACLs, %sxattrs, %siconv, %ssymtimes, %sprealloc\n", have_inplace, acls, xattrs, iconv, symtimes, prealloc); #ifdef MAINTAINER_MODE rprintf(f, "Panic Action: \"%s\"\n", get_panic_action()); #endif #if SIZEOF_INT64 < 8 rprintf(f, "WARNING: no 64-bit integers on this platform!\n"); #endif if (sizeof (int64) != SIZEOF_INT64) { rprintf(f, "WARNING: size mismatch in SIZEOF_INT64 define (%d != %d)\n", (int) SIZEOF_INT64, (int) sizeof (int64)); } rprintf(f,"\n"); rprintf(f,"rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you\n"); rprintf(f,"are welcome to redistribute it under certain conditions. See the GNU\n"); rprintf(f,"General Public Licence for details.\n"); }
Bypass
0
static void print_rsync_version(enum logcode f) { char *subprotocol = ""; char const *got_socketpair = "no "; char const *have_inplace = "no "; char const *hardlinks = "no "; char const *prealloc = "no "; char const *symtimes = "no "; char const *acls = "no "; char const *xattrs = "no "; char const *links = "no "; char const *iconv = "no "; char const *ipv6 = "no "; STRUCT_STAT *dumstat; #if SUBPROTOCOL_VERSION != 0 if (asprintf(&subprotocol, ".PR%d", SUBPROTOCOL_VERSION) < 0) out_of_memory("print_rsync_version"); #endif #ifdef HAVE_SOCKETPAIR got_socketpair = ""; #endif #ifdef HAVE_FTRUNCATE have_inplace = ""; #endif #ifdef SUPPORT_HARD_LINKS hardlinks = ""; #endif #ifdef SUPPORT_PREALLOCATION prealloc = ""; #endif #ifdef SUPPORT_ACLS acls = ""; #endif #ifdef SUPPORT_XATTRS xattrs = ""; #endif #ifdef SUPPORT_LINKS links = ""; #endif #ifdef INET6 ipv6 = ""; #endif #ifdef ICONV_OPTION iconv = ""; #endif #ifdef CAN_SET_SYMLINK_TIMES symtimes = ""; #endif rprintf(f, "%s version %s protocol version %d%s\n", RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION, subprotocol); rprintf(f, "Copyright (C) 1996-2015 by Andrew Tridgell, Wayne Davison, and others.\n"); rprintf(f, "Web site: http://rsync.samba.org/\n"); rprintf(f, "Capabilities:\n"); rprintf(f, " %d-bit files, %d-bit inums, %d-bit timestamps, %d-bit long ints,\n", (int)(sizeof (OFF_T) * 8), (int)(sizeof dumstat->st_ino * 8), /* Don't check ino_t! */ (int)(sizeof (time_t) * 8), (int)(sizeof (int64) * 8)); rprintf(f, " %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n", got_socketpair, hardlinks, links, ipv6, have_inplace); rprintf(f, " %sappend, %sACLs, %sxattrs, %siconv, %ssymtimes, %sprealloc\n", have_inplace, acls, xattrs, iconv, symtimes, prealloc); #ifdef MAINTAINER_MODE rprintf(f, "Panic Action: \"%s\"\n", get_panic_action()); #endif #if SIZEOF_INT64 < 8 rprintf(f, "WARNING: no 64-bit integers on this platform!\n"); #endif if (sizeof (int64) != SIZEOF_INT64) { rprintf(f, "WARNING: size mismatch in SIZEOF_INT64 define (%d != %d)\n", (int) SIZEOF_INT64, (int) sizeof (int64)); } rprintf(f,"\n"); rprintf(f,"rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you\n"); rprintf(f,"are welcome to redistribute it under certain conditions. See the GNU\n"); rprintf(f,"General Public Licence for details.\n"); }
@@ -1313,6 +1313,7 @@ int parse_arguments(int *argc_p, const char ***argv_p) const char *arg, **argv = *argv_p; int argc = *argc_p; int opt; + int orig_protect_args = protect_args; if (ref && *ref) set_refuse_options(ref); @@ -1934,6 +1935,10 @@ int parse_arguments(int *argc_p, const char ***argv_p) if (fuzzy_basis > 1) fuzzy_basis = basis_dir_cnt + 1; + /* Don't let the client reset protect_args if it was already processed */ + if (orig_protect_args == 2 && am_server) + protect_args = orig_protect_args; + if (protect_args == 1 && am_server) return 1;
null
null
null
9,466
void reset_output_levels(void) { int j; memset(info_levels, 0, sizeof info_levels); memset(debug_levels, 0, sizeof debug_levels); for (j = 0; j < COUNT_INFO; j++) info_words[j].priority = DEFAULT_PRIORITY; for (j = 0; j < COUNT_DEBUG; j++) debug_words[j].priority = DEFAULT_PRIORITY; }
Bypass
0
void reset_output_levels(void) { int j; memset(info_levels, 0, sizeof info_levels); memset(debug_levels, 0, sizeof debug_levels); for (j = 0; j < COUNT_INFO; j++) info_words[j].priority = DEFAULT_PRIORITY; for (j = 0; j < COUNT_DEBUG; j++) debug_words[j].priority = DEFAULT_PRIORITY; }
@@ -1313,6 +1313,7 @@ int parse_arguments(int *argc_p, const char ***argv_p) const char *arg, **argv = *argv_p; int argc = *argc_p; int opt; + int orig_protect_args = protect_args; if (ref && *ref) set_refuse_options(ref); @@ -1934,6 +1935,10 @@ int parse_arguments(int *argc_p, const char ***argv_p) if (fuzzy_basis > 1) fuzzy_basis = basis_dir_cnt + 1; + /* Don't let the client reset protect_args if it was already processed */ + if (orig_protect_args == 2 && am_server) + protect_args = orig_protect_args; + if (protect_args == 1 && am_server) return 1;
null
null
null
9,467
static void set_output_verbosity(int level, uchar priority) { int j; if (level > MAX_VERBOSITY) level = MAX_VERBOSITY; for (j = 1; j <= level; j++) { parse_output_words(info_words, info_levels, info_verbosity[j], priority); parse_output_words(debug_words, debug_levels, debug_verbosity[j], priority); } }
Bypass
0
static void set_output_verbosity(int level, uchar priority) { int j; if (level > MAX_VERBOSITY) level = MAX_VERBOSITY; for (j = 1; j <= level; j++) { parse_output_words(info_words, info_levels, info_verbosity[j], priority); parse_output_words(debug_words, debug_levels, debug_verbosity[j], priority); } }
@@ -1313,6 +1313,7 @@ int parse_arguments(int *argc_p, const char ***argv_p) const char *arg, **argv = *argv_p; int argc = *argc_p; int opt; + int orig_protect_args = protect_args; if (ref && *ref) set_refuse_options(ref); @@ -1934,6 +1935,10 @@ int parse_arguments(int *argc_p, const char ***argv_p) if (fuzzy_basis > 1) fuzzy_basis = basis_dir_cnt + 1; + /* Don't let the client reset protect_args if it was already processed */ + if (orig_protect_args == 2 && am_server) + protect_args = orig_protect_args; + if (protect_args == 1 && am_server) return 1;
null
null
null
9,468
static void set_refuse_options(char *bp) { struct poptOption *op; char *cp, shortname[2]; int is_wild, found_match; shortname[1] = '\0'; while (1) { while (*bp == ' ') bp++; if (!*bp) break; if ((cp = strchr(bp, ' ')) != NULL) *cp= '\0'; is_wild = strpbrk(bp, "*?[") != NULL; found_match = 0; for (op = long_options; ; op++) { *shortname = op->shortName; if (!op->longName && !*shortname) break; if ((op->longName && wildmatch(bp, op->longName)) || (*shortname && wildmatch(bp, shortname))) { if (op->argInfo == POPT_ARG_VAL) op->argInfo = POPT_ARG_NONE; op->val = (op - long_options) + OPT_REFUSED_BASE; found_match = 1; /* These flags are set to let us easily check * an implied option later in the code. */ switch (*shortname) { case 'r': case 'd': case 'l': case 'p': case 't': case 'g': case 'o': case 'D': refused_archive_part = op->val; break; case 'z': refused_compress = op->val; break; case '\0': if (wildmatch("delete", op->longName)) refused_delete = op->val; else if (wildmatch("delete-before", op->longName)) refused_delete_before = op->val; else if (wildmatch("delete-during", op->longName)) refused_delete_during = op->val; else if (wildmatch("partial", op->longName)) refused_partial = op->val; else if (wildmatch("progress", op->longName)) refused_progress = op->val; else if (wildmatch("inplace", op->longName)) refused_inplace = op->val; else if (wildmatch("no-iconv", op->longName)) refused_no_iconv = op->val; break; } if (!is_wild) break; } } if (!found_match) { rprintf(FLOG, "No match for refuse-options string \"%s\"\n", bp); } if (!cp) break; *cp = ' '; bp = cp + 1; } }
Bypass
0
static void set_refuse_options(char *bp) { struct poptOption *op; char *cp, shortname[2]; int is_wild, found_match; shortname[1] = '\0'; while (1) { while (*bp == ' ') bp++; if (!*bp) break; if ((cp = strchr(bp, ' ')) != NULL) *cp= '\0'; is_wild = strpbrk(bp, "*?[") != NULL; found_match = 0; for (op = long_options; ; op++) { *shortname = op->shortName; if (!op->longName && !*shortname) break; if ((op->longName && wildmatch(bp, op->longName)) || (*shortname && wildmatch(bp, shortname))) { if (op->argInfo == POPT_ARG_VAL) op->argInfo = POPT_ARG_NONE; op->val = (op - long_options) + OPT_REFUSED_BASE; found_match = 1; /* These flags are set to let us easily check * an implied option later in the code. */ switch (*shortname) { case 'r': case 'd': case 'l': case 'p': case 't': case 'g': case 'o': case 'D': refused_archive_part = op->val; break; case 'z': refused_compress = op->val; break; case '\0': if (wildmatch("delete", op->longName)) refused_delete = op->val; else if (wildmatch("delete-before", op->longName)) refused_delete_before = op->val; else if (wildmatch("delete-during", op->longName)) refused_delete_during = op->val; else if (wildmatch("partial", op->longName)) refused_partial = op->val; else if (wildmatch("progress", op->longName)) refused_progress = op->val; else if (wildmatch("inplace", op->longName)) refused_inplace = op->val; else if (wildmatch("no-iconv", op->longName)) refused_no_iconv = op->val; break; } if (!is_wild) break; } } if (!found_match) { rprintf(FLOG, "No match for refuse-options string \"%s\"\n", bp); } if (!cp) break; *cp = ' '; bp = cp + 1; } }
@@ -1313,6 +1313,7 @@ int parse_arguments(int *argc_p, const char ***argv_p) const char *arg, **argv = *argv_p; int argc = *argc_p; int opt; + int orig_protect_args = protect_args; if (ref && *ref) set_refuse_options(ref); @@ -1934,6 +1935,10 @@ int parse_arguments(int *argc_p, const char ***argv_p) if (fuzzy_basis > 1) fuzzy_basis = basis_dir_cnt + 1; + /* Don't let the client reset protect_args if it was already processed */ + if (orig_protect_args == 2 && am_server) + protect_args = orig_protect_args; + if (protect_args == 1 && am_server) return 1;
null
null
null
9,469
void usage(enum logcode F) { print_rsync_version(F); rprintf(F,"\n"); rprintf(F,"rsync is a file transfer program capable of efficient remote update\n"); rprintf(F,"via a fast differencing algorithm.\n"); rprintf(F,"\n"); rprintf(F,"Usage: rsync [OPTION]... SRC [SRC]... DEST\n"); rprintf(F," or rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST\n"); rprintf(F," or rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST\n"); rprintf(F," or rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST\n"); rprintf(F," or rsync [OPTION]... [USER@]HOST:SRC [DEST]\n"); rprintf(F," or rsync [OPTION]... [USER@]HOST::SRC [DEST]\n"); rprintf(F," or rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]\n"); rprintf(F,"The ':' usages connect via remote shell, while '::' & 'rsync://' usages connect\n"); rprintf(F,"to an rsync daemon, and require SRC or DEST to start with a module name.\n"); rprintf(F,"\n"); rprintf(F,"Options\n"); rprintf(F," -v, --verbose increase verbosity\n"); rprintf(F," --info=FLAGS fine-grained informational verbosity\n"); rprintf(F," --debug=FLAGS fine-grained debug verbosity\n"); rprintf(F," --msgs2stderr special output handling for debugging\n"); rprintf(F," -q, --quiet suppress non-error messages\n"); rprintf(F," --no-motd suppress daemon-mode MOTD (see manpage caveat)\n"); rprintf(F," -c, --checksum skip based on checksum, not mod-time & size\n"); rprintf(F," -a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)\n"); rprintf(F," --no-OPTION turn off an implied OPTION (e.g. --no-D)\n"); rprintf(F," -r, --recursive recurse into directories\n"); rprintf(F," -R, --relative use relative path names\n"); rprintf(F," --no-implied-dirs don't send implied dirs with --relative\n"); rprintf(F," -b, --backup make backups (see --suffix & --backup-dir)\n"); rprintf(F," --backup-dir=DIR make backups into hierarchy based in DIR\n"); rprintf(F," --suffix=SUFFIX set backup suffix (default %s w/o --backup-dir)\n",BACKUP_SUFFIX); rprintf(F," -u, --update skip files that are newer on the receiver\n"); rprintf(F," --inplace update destination files in-place (SEE MAN PAGE)\n"); rprintf(F," --append append data onto shorter files\n"); rprintf(F," --append-verify like --append, but with old data in file checksum\n"); rprintf(F," -d, --dirs transfer directories without recursing\n"); rprintf(F," -l, --links copy symlinks as symlinks\n"); rprintf(F," -L, --copy-links transform symlink into referent file/dir\n"); rprintf(F," --copy-unsafe-links only \"unsafe\" symlinks are transformed\n"); rprintf(F," --safe-links ignore symlinks that point outside the source tree\n"); rprintf(F," --munge-links munge symlinks to make them safer (but unusable)\n"); rprintf(F," -k, --copy-dirlinks transform symlink to a dir into referent dir\n"); rprintf(F," -K, --keep-dirlinks treat symlinked dir on receiver as dir\n"); rprintf(F," -H, --hard-links preserve hard links\n"); rprintf(F," -p, --perms preserve permissions\n"); rprintf(F," -E, --executability preserve the file's executability\n"); rprintf(F," --chmod=CHMOD affect file and/or directory permissions\n"); #ifdef SUPPORT_ACLS rprintf(F," -A, --acls preserve ACLs (implies --perms)\n"); #endif #ifdef SUPPORT_XATTRS rprintf(F," -X, --xattrs preserve extended attributes\n"); #endif rprintf(F," -o, --owner preserve owner (super-user only)\n"); rprintf(F," -g, --group preserve group\n"); rprintf(F," --devices preserve device files (super-user only)\n"); rprintf(F," --specials preserve special files\n"); rprintf(F," -D same as --devices --specials\n"); rprintf(F," -t, --times preserve modification times\n"); rprintf(F," -O, --omit-dir-times omit directories from --times\n"); rprintf(F," -J, --omit-link-times omit symlinks from --times\n"); rprintf(F," --super receiver attempts super-user activities\n"); #ifdef SUPPORT_XATTRS rprintf(F," --fake-super store/recover privileged attrs using xattrs\n"); #endif rprintf(F," -S, --sparse turn sequences of nulls into sparse blocks\n"); #ifdef SUPPORT_PREALLOCATION rprintf(F," --preallocate allocate dest files before writing them\n"); #else rprintf(F," --preallocate pre-allocate dest files on remote receiver\n"); #endif rprintf(F," -n, --dry-run perform a trial run with no changes made\n"); rprintf(F," -W, --whole-file copy files whole (without delta-xfer algorithm)\n"); rprintf(F," --checksum-choice=STR choose the checksum algorithms\n"); rprintf(F," -x, --one-file-system don't cross filesystem boundaries\n"); rprintf(F," -B, --block-size=SIZE force a fixed checksum block-size\n"); rprintf(F," -e, --rsh=COMMAND specify the remote shell to use\n"); rprintf(F," --rsync-path=PROGRAM specify the rsync to run on the remote machine\n"); rprintf(F," --existing skip creating new files on receiver\n"); rprintf(F," --ignore-existing skip updating files that already exist on receiver\n"); rprintf(F," --remove-source-files sender removes synchronized files (non-dirs)\n"); rprintf(F," --del an alias for --delete-during\n"); rprintf(F," --delete delete extraneous files from destination dirs\n"); rprintf(F," --delete-before receiver deletes before transfer, not during\n"); rprintf(F," --delete-during receiver deletes during the transfer\n"); rprintf(F," --delete-delay find deletions during, delete after\n"); rprintf(F," --delete-after receiver deletes after transfer, not during\n"); rprintf(F," --delete-excluded also delete excluded files from destination dirs\n"); rprintf(F," --ignore-missing-args ignore missing source args without error\n"); rprintf(F," --delete-missing-args delete missing source args from destination\n"); rprintf(F," --ignore-errors delete even if there are I/O errors\n"); rprintf(F," --force force deletion of directories even if not empty\n"); rprintf(F," --max-delete=NUM don't delete more than NUM files\n"); rprintf(F," --max-size=SIZE don't transfer any file larger than SIZE\n"); rprintf(F," --min-size=SIZE don't transfer any file smaller than SIZE\n"); rprintf(F," --partial keep partially transferred files\n"); rprintf(F," --partial-dir=DIR put a partially transferred file into DIR\n"); rprintf(F," --delay-updates put all updated files into place at transfer's end\n"); rprintf(F," -m, --prune-empty-dirs prune empty directory chains from the file-list\n"); rprintf(F," --numeric-ids don't map uid/gid values by user/group name\n"); rprintf(F," --usermap=STRING custom username mapping\n"); rprintf(F," --groupmap=STRING custom groupname mapping\n"); rprintf(F," --chown=USER:GROUP simple username/groupname mapping\n"); rprintf(F," --timeout=SECONDS set I/O timeout in seconds\n"); rprintf(F," --contimeout=SECONDS set daemon connection timeout in seconds\n"); rprintf(F," -I, --ignore-times don't skip files that match in size and mod-time\n"); rprintf(F," -M, --remote-option=OPTION send OPTION to the remote side only\n"); rprintf(F," --size-only skip files that match in size\n"); rprintf(F," -@, --modify-window=NUM set the accuracy for mod-time comparisons\n"); rprintf(F," -T, --temp-dir=DIR create temporary files in directory DIR\n"); rprintf(F," -y, --fuzzy find similar file for basis if no dest file\n"); rprintf(F," --compare-dest=DIR also compare destination files relative to DIR\n"); rprintf(F," --copy-dest=DIR ... and include copies of unchanged files\n"); rprintf(F," --link-dest=DIR hardlink to files in DIR when unchanged\n"); rprintf(F," -z, --compress compress file data during the transfer\n"); rprintf(F," --compress-level=NUM explicitly set compression level\n"); rprintf(F," --skip-compress=LIST skip compressing files with a suffix in LIST\n"); rprintf(F," -C, --cvs-exclude auto-ignore files the same way CVS does\n"); rprintf(F," -f, --filter=RULE add a file-filtering RULE\n"); rprintf(F," -F same as --filter='dir-merge /.rsync-filter'\n"); rprintf(F," repeated: --filter='- .rsync-filter'\n"); rprintf(F," --exclude=PATTERN exclude files matching PATTERN\n"); rprintf(F," --exclude-from=FILE read exclude patterns from FILE\n"); rprintf(F," --include=PATTERN don't exclude files matching PATTERN\n"); rprintf(F," --include-from=FILE read include patterns from FILE\n"); rprintf(F," --files-from=FILE read list of source-file names from FILE\n"); rprintf(F," -0, --from0 all *-from/filter files are delimited by 0s\n"); rprintf(F," -s, --protect-args no space-splitting; only wildcard special-chars\n"); rprintf(F," --address=ADDRESS bind address for outgoing socket to daemon\n"); rprintf(F," --port=PORT specify double-colon alternate port number\n"); rprintf(F," --sockopts=OPTIONS specify custom TCP options\n"); rprintf(F," --blocking-io use blocking I/O for the remote shell\n"); rprintf(F," --stats give some file-transfer stats\n"); rprintf(F," -8, --8-bit-output leave high-bit chars unescaped in output\n"); rprintf(F," -h, --human-readable output numbers in a human-readable format\n"); rprintf(F," --progress show progress during transfer\n"); rprintf(F," -P same as --partial --progress\n"); rprintf(F," -i, --itemize-changes output a change-summary for all updates\n"); rprintf(F," --out-format=FORMAT output updates using the specified FORMAT\n"); rprintf(F," --log-file=FILE log what we're doing to the specified FILE\n"); rprintf(F," --log-file-format=FMT log updates using the specified FMT\n"); rprintf(F," --password-file=FILE read daemon-access password from FILE\n"); rprintf(F," --list-only list the files instead of copying them\n"); rprintf(F," --bwlimit=RATE limit socket I/O bandwidth\n"); #ifdef HAVE_SETVBUF rprintf(F," --outbuf=N|L|B set output buffering to None, Line, or Block\n"); #endif rprintf(F," --write-batch=FILE write a batched update to FILE\n"); rprintf(F," --only-write-batch=FILE like --write-batch but w/o updating destination\n"); rprintf(F," --read-batch=FILE read a batched update from FILE\n"); rprintf(F," --protocol=NUM force an older protocol version to be used\n"); #ifdef ICONV_OPTION rprintf(F," --iconv=CONVERT_SPEC request charset conversion of filenames\n"); #endif rprintf(F," --checksum-seed=NUM set block/file checksum seed (advanced)\n"); rprintf(F," -4, --ipv4 prefer IPv4\n"); rprintf(F," -6, --ipv6 prefer IPv6\n"); rprintf(F," --version print version number\n"); rprintf(F,"(-h) --help show this help (-h is --help only if used alone)\n"); rprintf(F,"\n"); rprintf(F,"Use \"rsync --daemon --help\" to see the daemon-mode command-line options.\n"); rprintf(F,"Please see the rsync(1) and rsyncd.conf(5) man pages for full documentation.\n"); rprintf(F,"See http://rsync.samba.org/ for updates, bug reports, and answers\n"); }
Bypass
0
void usage(enum logcode F) { print_rsync_version(F); rprintf(F,"\n"); rprintf(F,"rsync is a file transfer program capable of efficient remote update\n"); rprintf(F,"via a fast differencing algorithm.\n"); rprintf(F,"\n"); rprintf(F,"Usage: rsync [OPTION]... SRC [SRC]... DEST\n"); rprintf(F," or rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST\n"); rprintf(F," or rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST\n"); rprintf(F," or rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST\n"); rprintf(F," or rsync [OPTION]... [USER@]HOST:SRC [DEST]\n"); rprintf(F," or rsync [OPTION]... [USER@]HOST::SRC [DEST]\n"); rprintf(F," or rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]\n"); rprintf(F,"The ':' usages connect via remote shell, while '::' & 'rsync://' usages connect\n"); rprintf(F,"to an rsync daemon, and require SRC or DEST to start with a module name.\n"); rprintf(F,"\n"); rprintf(F,"Options\n"); rprintf(F," -v, --verbose increase verbosity\n"); rprintf(F," --info=FLAGS fine-grained informational verbosity\n"); rprintf(F," --debug=FLAGS fine-grained debug verbosity\n"); rprintf(F," --msgs2stderr special output handling for debugging\n"); rprintf(F," -q, --quiet suppress non-error messages\n"); rprintf(F," --no-motd suppress daemon-mode MOTD (see manpage caveat)\n"); rprintf(F," -c, --checksum skip based on checksum, not mod-time & size\n"); rprintf(F," -a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)\n"); rprintf(F," --no-OPTION turn off an implied OPTION (e.g. --no-D)\n"); rprintf(F," -r, --recursive recurse into directories\n"); rprintf(F," -R, --relative use relative path names\n"); rprintf(F," --no-implied-dirs don't send implied dirs with --relative\n"); rprintf(F," -b, --backup make backups (see --suffix & --backup-dir)\n"); rprintf(F," --backup-dir=DIR make backups into hierarchy based in DIR\n"); rprintf(F," --suffix=SUFFIX set backup suffix (default %s w/o --backup-dir)\n",BACKUP_SUFFIX); rprintf(F," -u, --update skip files that are newer on the receiver\n"); rprintf(F," --inplace update destination files in-place (SEE MAN PAGE)\n"); rprintf(F," --append append data onto shorter files\n"); rprintf(F," --append-verify like --append, but with old data in file checksum\n"); rprintf(F," -d, --dirs transfer directories without recursing\n"); rprintf(F," -l, --links copy symlinks as symlinks\n"); rprintf(F," -L, --copy-links transform symlink into referent file/dir\n"); rprintf(F," --copy-unsafe-links only \"unsafe\" symlinks are transformed\n"); rprintf(F," --safe-links ignore symlinks that point outside the source tree\n"); rprintf(F," --munge-links munge symlinks to make them safer (but unusable)\n"); rprintf(F," -k, --copy-dirlinks transform symlink to a dir into referent dir\n"); rprintf(F," -K, --keep-dirlinks treat symlinked dir on receiver as dir\n"); rprintf(F," -H, --hard-links preserve hard links\n"); rprintf(F," -p, --perms preserve permissions\n"); rprintf(F," -E, --executability preserve the file's executability\n"); rprintf(F," --chmod=CHMOD affect file and/or directory permissions\n"); #ifdef SUPPORT_ACLS rprintf(F," -A, --acls preserve ACLs (implies --perms)\n"); #endif #ifdef SUPPORT_XATTRS rprintf(F," -X, --xattrs preserve extended attributes\n"); #endif rprintf(F," -o, --owner preserve owner (super-user only)\n"); rprintf(F," -g, --group preserve group\n"); rprintf(F," --devices preserve device files (super-user only)\n"); rprintf(F," --specials preserve special files\n"); rprintf(F," -D same as --devices --specials\n"); rprintf(F," -t, --times preserve modification times\n"); rprintf(F," -O, --omit-dir-times omit directories from --times\n"); rprintf(F," -J, --omit-link-times omit symlinks from --times\n"); rprintf(F," --super receiver attempts super-user activities\n"); #ifdef SUPPORT_XATTRS rprintf(F," --fake-super store/recover privileged attrs using xattrs\n"); #endif rprintf(F," -S, --sparse turn sequences of nulls into sparse blocks\n"); #ifdef SUPPORT_PREALLOCATION rprintf(F," --preallocate allocate dest files before writing them\n"); #else rprintf(F," --preallocate pre-allocate dest files on remote receiver\n"); #endif rprintf(F," -n, --dry-run perform a trial run with no changes made\n"); rprintf(F," -W, --whole-file copy files whole (without delta-xfer algorithm)\n"); rprintf(F," --checksum-choice=STR choose the checksum algorithms\n"); rprintf(F," -x, --one-file-system don't cross filesystem boundaries\n"); rprintf(F," -B, --block-size=SIZE force a fixed checksum block-size\n"); rprintf(F," -e, --rsh=COMMAND specify the remote shell to use\n"); rprintf(F," --rsync-path=PROGRAM specify the rsync to run on the remote machine\n"); rprintf(F," --existing skip creating new files on receiver\n"); rprintf(F," --ignore-existing skip updating files that already exist on receiver\n"); rprintf(F," --remove-source-files sender removes synchronized files (non-dirs)\n"); rprintf(F," --del an alias for --delete-during\n"); rprintf(F," --delete delete extraneous files from destination dirs\n"); rprintf(F," --delete-before receiver deletes before transfer, not during\n"); rprintf(F," --delete-during receiver deletes during the transfer\n"); rprintf(F," --delete-delay find deletions during, delete after\n"); rprintf(F," --delete-after receiver deletes after transfer, not during\n"); rprintf(F," --delete-excluded also delete excluded files from destination dirs\n"); rprintf(F," --ignore-missing-args ignore missing source args without error\n"); rprintf(F," --delete-missing-args delete missing source args from destination\n"); rprintf(F," --ignore-errors delete even if there are I/O errors\n"); rprintf(F," --force force deletion of directories even if not empty\n"); rprintf(F," --max-delete=NUM don't delete more than NUM files\n"); rprintf(F," --max-size=SIZE don't transfer any file larger than SIZE\n"); rprintf(F," --min-size=SIZE don't transfer any file smaller than SIZE\n"); rprintf(F," --partial keep partially transferred files\n"); rprintf(F," --partial-dir=DIR put a partially transferred file into DIR\n"); rprintf(F," --delay-updates put all updated files into place at transfer's end\n"); rprintf(F," -m, --prune-empty-dirs prune empty directory chains from the file-list\n"); rprintf(F," --numeric-ids don't map uid/gid values by user/group name\n"); rprintf(F," --usermap=STRING custom username mapping\n"); rprintf(F," --groupmap=STRING custom groupname mapping\n"); rprintf(F," --chown=USER:GROUP simple username/groupname mapping\n"); rprintf(F," --timeout=SECONDS set I/O timeout in seconds\n"); rprintf(F," --contimeout=SECONDS set daemon connection timeout in seconds\n"); rprintf(F," -I, --ignore-times don't skip files that match in size and mod-time\n"); rprintf(F," -M, --remote-option=OPTION send OPTION to the remote side only\n"); rprintf(F," --size-only skip files that match in size\n"); rprintf(F," -@, --modify-window=NUM set the accuracy for mod-time comparisons\n"); rprintf(F," -T, --temp-dir=DIR create temporary files in directory DIR\n"); rprintf(F," -y, --fuzzy find similar file for basis if no dest file\n"); rprintf(F," --compare-dest=DIR also compare destination files relative to DIR\n"); rprintf(F," --copy-dest=DIR ... and include copies of unchanged files\n"); rprintf(F," --link-dest=DIR hardlink to files in DIR when unchanged\n"); rprintf(F," -z, --compress compress file data during the transfer\n"); rprintf(F," --compress-level=NUM explicitly set compression level\n"); rprintf(F," --skip-compress=LIST skip compressing files with a suffix in LIST\n"); rprintf(F," -C, --cvs-exclude auto-ignore files the same way CVS does\n"); rprintf(F," -f, --filter=RULE add a file-filtering RULE\n"); rprintf(F," -F same as --filter='dir-merge /.rsync-filter'\n"); rprintf(F," repeated: --filter='- .rsync-filter'\n"); rprintf(F," --exclude=PATTERN exclude files matching PATTERN\n"); rprintf(F," --exclude-from=FILE read exclude patterns from FILE\n"); rprintf(F," --include=PATTERN don't exclude files matching PATTERN\n"); rprintf(F," --include-from=FILE read include patterns from FILE\n"); rprintf(F," --files-from=FILE read list of source-file names from FILE\n"); rprintf(F," -0, --from0 all *-from/filter files are delimited by 0s\n"); rprintf(F," -s, --protect-args no space-splitting; only wildcard special-chars\n"); rprintf(F," --address=ADDRESS bind address for outgoing socket to daemon\n"); rprintf(F," --port=PORT specify double-colon alternate port number\n"); rprintf(F," --sockopts=OPTIONS specify custom TCP options\n"); rprintf(F," --blocking-io use blocking I/O for the remote shell\n"); rprintf(F," --stats give some file-transfer stats\n"); rprintf(F," -8, --8-bit-output leave high-bit chars unescaped in output\n"); rprintf(F," -h, --human-readable output numbers in a human-readable format\n"); rprintf(F," --progress show progress during transfer\n"); rprintf(F," -P same as --partial --progress\n"); rprintf(F," -i, --itemize-changes output a change-summary for all updates\n"); rprintf(F," --out-format=FORMAT output updates using the specified FORMAT\n"); rprintf(F," --log-file=FILE log what we're doing to the specified FILE\n"); rprintf(F," --log-file-format=FMT log updates using the specified FMT\n"); rprintf(F," --password-file=FILE read daemon-access password from FILE\n"); rprintf(F," --list-only list the files instead of copying them\n"); rprintf(F," --bwlimit=RATE limit socket I/O bandwidth\n"); #ifdef HAVE_SETVBUF rprintf(F," --outbuf=N|L|B set output buffering to None, Line, or Block\n"); #endif rprintf(F," --write-batch=FILE write a batched update to FILE\n"); rprintf(F," --only-write-batch=FILE like --write-batch but w/o updating destination\n"); rprintf(F," --read-batch=FILE read a batched update from FILE\n"); rprintf(F," --protocol=NUM force an older protocol version to be used\n"); #ifdef ICONV_OPTION rprintf(F," --iconv=CONVERT_SPEC request charset conversion of filenames\n"); #endif rprintf(F," --checksum-seed=NUM set block/file checksum seed (advanced)\n"); rprintf(F," -4, --ipv4 prefer IPv4\n"); rprintf(F," -6, --ipv6 prefer IPv6\n"); rprintf(F," --version print version number\n"); rprintf(F,"(-h) --help show this help (-h is --help only if used alone)\n"); rprintf(F,"\n"); rprintf(F,"Use \"rsync --daemon --help\" to see the daemon-mode command-line options.\n"); rprintf(F,"Please see the rsync(1) and rsyncd.conf(5) man pages for full documentation.\n"); rprintf(F,"See http://rsync.samba.org/ for updates, bug reports, and answers\n"); }
@@ -1313,6 +1313,7 @@ int parse_arguments(int *argc_p, const char ***argv_p) const char *arg, **argv = *argv_p; int argc = *argc_p; int opt; + int orig_protect_args = protect_args; if (ref && *ref) set_refuse_options(ref); @@ -1934,6 +1935,10 @@ int parse_arguments(int *argc_p, const char ***argv_p) if (fuzzy_basis > 1) fuzzy_basis = basis_dir_cnt + 1; + /* Don't let the client reset protect_args if it was already processed */ + if (orig_protect_args == 2 && am_server) + protect_args = orig_protect_args; + if (protect_args == 1 && am_server) return 1;
null
null
null
9,470
static js_Ast *arguments(js_State *J) { js_Ast *head, *tail; if (J->lookahead == ')') return NULL; head = tail = LIST(assignment(J, 0)); while (jsP_accept(J, ',')) { tail = tail->b = LIST(assignment(J, 0)); } return jsP_list(head); }
DoS
0
static js_Ast *arguments(js_State *J) { js_Ast *head, *tail; if (J->lookahead == ')') return NULL; head = tail = LIST(assignment(J, 0)); while (jsP_accept(J, ',')) { tail = tail->b = LIST(assignment(J, 0)); } return jsP_list(head); }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,471
static js_Ast *arrayelement(js_State *J) { if (J->lookahead == ',') return EXP0(UNDEF); return assignment(J, 0); }
DoS
0
static js_Ast *arrayelement(js_State *J) { if (J->lookahead == ',') return EXP0(UNDEF); return assignment(J, 0); }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,472
static js_Ast *arrayliteral(js_State *J) { js_Ast *head, *tail; if (J->lookahead == ']') return NULL; head = tail = LIST(arrayelement(J)); while (jsP_accept(J, ',')) { if (J->lookahead != ']') tail = tail->b = LIST(arrayelement(J)); } return jsP_list(head); }
DoS
0
static js_Ast *arrayliteral(js_State *J) { js_Ast *head, *tail; if (J->lookahead == ']') return NULL; head = tail = LIST(arrayelement(J)); while (jsP_accept(J, ',')) { if (J->lookahead != ']') tail = tail->b = LIST(arrayelement(J)); } return jsP_list(head); }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,473
static js_Ast *funstm(js_State *J) { js_Ast *a, *b, *c; a = identifier(J); jsP_expect(J, '('); b = parameters(J); jsP_expect(J, ')'); c = funbody(J); /* rewrite function statement as "var X = function X() {}" */ return STM1(VAR, LIST(EXP2(VAR, a, EXP3(FUN, a, b, c)))); }
DoS
0
static js_Ast *funstm(js_State *J) { js_Ast *a, *b, *c; a = identifier(J); jsP_expect(J, '('); b = parameters(J); jsP_expect(J, ')'); c = funbody(J); /* rewrite function statement as "var X = function X() {}" */ return STM1(VAR, LIST(EXP2(VAR, a, EXP3(FUN, a, b, c)))); }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,474
static js_Ast *identifier(js_State *J) { js_Ast *a; if (J->lookahead == TK_IDENTIFIER) { a = jsP_newstrnode(J, AST_IDENTIFIER, J->text); jsP_next(J); return a; } jsP_error(J, "unexpected token: %s (expected identifier)", jsY_tokenstring(J->lookahead)); }
DoS
0
static js_Ast *identifier(js_State *J) { js_Ast *a; if (J->lookahead == TK_IDENTIFIER) { a = jsP_newstrnode(J, AST_IDENTIFIER, J->text); jsP_next(J); return a; } jsP_error(J, "unexpected token: %s (expected identifier)", jsY_tokenstring(J->lookahead)); }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,475
static js_Ast *identifiername(js_State *J) { if (J->lookahead == TK_IDENTIFIER || J->lookahead >= TK_BREAK) { js_Ast *a = jsP_newstrnode(J, AST_IDENTIFIER, J->text); jsP_next(J); return a; } jsP_error(J, "unexpected token: %s (expected identifier or keyword)", jsY_tokenstring(J->lookahead)); }
DoS
0
static js_Ast *identifiername(js_State *J) { if (J->lookahead == TK_IDENTIFIER || J->lookahead >= TK_BREAK) { js_Ast *a = jsP_newstrnode(J, AST_IDENTIFIER, J->text); jsP_next(J); return a; } jsP_error(J, "unexpected token: %s (expected identifier or keyword)", jsY_tokenstring(J->lookahead)); }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,476
static js_Ast *identifieropt(js_State *J) { if (J->lookahead == TK_IDENTIFIER) return identifier(J); return NULL; }
DoS
0
static js_Ast *identifieropt(js_State *J) { if (J->lookahead == TK_IDENTIFIER) return identifier(J); return NULL; }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,477
static void jsP_error(js_State *J, const char *fmt, ...) { char msgbuf[256]; va_start(ap, fmt); vsnprintf(msgbuf, 256, fmt, ap); va_end(ap); snprintf(buf, 256, "%s:%d: ", J->filename, J->lexline); strcat(buf, msgbuf); js_newsyntaxerror(J, buf); js_throw(J); }
DoS
0
static void jsP_error(js_State *J, const char *fmt, ...) { char msgbuf[256]; va_start(ap, fmt); vsnprintf(msgbuf, 256, fmt, ap); va_end(ap); snprintf(buf, 256, "%s:%d: ", J->filename, J->lexline); strcat(buf, msgbuf); js_newsyntaxerror(J, buf); js_throw(J); }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,478
static void jsP_freejumps(js_State *J, js_JumpList *node) { while (node) { js_JumpList *next = node->next; js_free(J, node); node = next; } }
DoS
0
static void jsP_freejumps(js_State *J, js_JumpList *node) { while (node) { js_JumpList *next = node->next; js_free(J, node); node = next; } }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,479
void jsP_freeparse(js_State *J) { js_Ast *node = J->gcast; while (node) { js_Ast *next = node->gcnext; jsP_freejumps(J, node->jumps); js_free(J, node); node = next; } J->gcast = NULL; }
DoS
0
void jsP_freeparse(js_State *J) { js_Ast *node = J->gcast; while (node) { js_Ast *next = node->gcnext; jsP_freejumps(J, node->jumps); js_free(J, node); node = next; } J->gcast = NULL; }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,480
static js_Ast *jsP_list(js_Ast *head) { /* set parent pointers in list nodes */ js_Ast *prev = head, *node = head->b; while (node) { node->parent = prev; prev = node; node = node->b; } return head; }
DoS
0
static js_Ast *jsP_list(js_Ast *head) { /* set parent pointers in list nodes */ js_Ast *prev = head, *node = head->b; while (node) { node->parent = prev; prev = node; node = node->b; } return head; }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,481
static js_Ast *jsP_newnode(js_State *J, enum js_AstType type, js_Ast *a, js_Ast *b, js_Ast *c, js_Ast *d) { js_Ast *node = js_malloc(J, sizeof *node); node->type = type; node->line = J->astline; node->a = a; node->b = b; node->c = c; node->d = d; node->number = 0; node->string = NULL; node->jumps = NULL; node->casejump = 0; node->parent = NULL; if (a) a->parent = node; if (b) b->parent = node; if (c) c->parent = node; if (d) d->parent = node; node->gcnext = J->gcast; J->gcast = node; return node; }
DoS
0
static js_Ast *jsP_newnode(js_State *J, enum js_AstType type, js_Ast *a, js_Ast *b, js_Ast *c, js_Ast *d) { js_Ast *node = js_malloc(J, sizeof *node); node->type = type; node->line = J->astline; node->a = a; node->b = b; node->c = c; node->d = d; node->number = 0; node->string = NULL; node->jumps = NULL; node->casejump = 0; node->parent = NULL; if (a) a->parent = node; if (b) b->parent = node; if (c) c->parent = node; if (d) d->parent = node; node->gcnext = J->gcast; J->gcast = node; return node; }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,482
static js_Ast *jsP_newnumnode(js_State *J, enum js_AstType type, double n) { js_Ast *node = jsP_newnode(J, type, 0, 0, 0, 0); node->number = n; return node; }
DoS
0
static js_Ast *jsP_newnumnode(js_State *J, enum js_AstType type, double n) { js_Ast *node = jsP_newnode(J, type, 0, 0, 0, 0); node->number = n; return node; }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,483
static js_Ast *jsP_newstrnode(js_State *J, enum js_AstType type, const char *s) { js_Ast *node = jsP_newnode(J, type, 0, 0, 0, 0); node->string = s; return node; }
DoS
0
static js_Ast *jsP_newstrnode(js_State *J, enum js_AstType type, const char *s) { js_Ast *node = jsP_newnode(J, type, 0, 0, 0, 0); node->string = s; return node; }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,484
static void jsP_next(js_State *J) { J->lookahead = jsY_lex(J); J->astline = J->lexline; }
DoS
0
static void jsP_next(js_State *J) { J->lookahead = jsY_lex(J); J->astline = J->lexline; }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,485
static void jsP_warning(js_State *J, const char *fmt, ...) { va_list ap; char buf[512]; char msg[256]; va_start(ap, fmt); vsnprintf(msg, sizeof msg, fmt, ap); va_end(ap); snprintf(buf, sizeof buf, "%s:%d: warning: %s", J->filename, J->lexline, msg); js_report(J, buf); }
DoS
0
static void jsP_warning(js_State *J, const char *fmt, ...) { va_list ap; char buf[512]; char msg[256]; va_start(ap, fmt); vsnprintf(msg, sizeof msg, fmt, ap); va_end(ap); snprintf(buf, sizeof buf, "%s:%d: warning: %s", J->filename, J->lexline, msg); js_report(J, buf); }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,486
static js_Ast *newexp(js_State *J) { js_Ast *a, *b; if (jsP_accept(J, TK_NEW)) { a = memberexp(J); if (jsP_accept(J, '(')) { b = arguments(J); jsP_expect(J, ')'); return EXP2(NEW, a, b); } return EXP1(NEW, a); } if (jsP_accept(J, TK_FUNCTION)) return funexp(J); return primary(J); }
DoS
0
static js_Ast *newexp(js_State *J) { js_Ast *a, *b; if (jsP_accept(J, TK_NEW)) { a = memberexp(J); if (jsP_accept(J, '(')) { b = arguments(J); jsP_expect(J, ')'); return EXP2(NEW, a, b); } return EXP1(NEW, a); } if (jsP_accept(J, TK_FUNCTION)) return funexp(J); return primary(J); }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,487
static js_Ast *objectliteral(js_State *J) { js_Ast *head, *tail; if (J->lookahead == '}')
DoS
0
static js_Ast *objectliteral(js_State *J) { js_Ast *head, *tail; if (J->lookahead == '}')
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,488
static js_Ast *parameters(js_State *J) { js_Ast *head, *tail; if (J->lookahead == ')') return NULL; head = tail = LIST(identifier(J)); while (jsP_accept(J, ',')) { tail = tail->b = LIST(identifier(J)); } return jsP_list(head); }
DoS
0
static js_Ast *parameters(js_State *J) { js_Ast *head, *tail; if (J->lookahead == ')') return NULL; head = tail = LIST(identifier(J)); while (jsP_accept(J, ',')) { tail = tail->b = LIST(identifier(J)); } return jsP_list(head); }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,489
static js_Ast *primary(js_State *J) { js_Ast *a; if (J->lookahead == TK_IDENTIFIER) { a = jsP_newstrnode(J, EXP_IDENTIFIER, J->text); jsP_next(J); return a; } if (J->lookahead == TK_STRING) { a = jsP_newstrnode(J, EXP_STRING, J->text); jsP_next(J); return a; } if (J->lookahead == TK_REGEXP) { a = jsP_newstrnode(J, EXP_REGEXP, J->text); a->number = J->number; jsP_next(J); return a; } if (J->lookahead == TK_NUMBER) { a = jsP_newnumnode(J, EXP_NUMBER, J->number); jsP_next(J); return a; } if (jsP_accept(J, TK_THIS)) return EXP0(THIS); if (jsP_accept(J, TK_NULL)) return EXP0(NULL); if (jsP_accept(J, TK_TRUE)) return EXP0(TRUE); if (jsP_accept(J, TK_FALSE)) return EXP0(FALSE); if (jsP_accept(J, '{')) { a = EXP1(OBJECT, objectliteral(J)); jsP_expect(J, '}'); return a; } if (jsP_accept(J, '[')) { a = EXP1(ARRAY, arrayliteral(J)); jsP_expect(J, ']'); return a; } if (jsP_accept(J, '(')) { a = expression(J, 0); jsP_expect(J, ')'); return a; } jsP_error(J, "unexpected token in expression: %s", jsY_tokenstring(J->lookahead)); }
DoS
0
static js_Ast *primary(js_State *J) { js_Ast *a; if (J->lookahead == TK_IDENTIFIER) { a = jsP_newstrnode(J, EXP_IDENTIFIER, J->text); jsP_next(J); return a; } if (J->lookahead == TK_STRING) { a = jsP_newstrnode(J, EXP_STRING, J->text); jsP_next(J); return a; } if (J->lookahead == TK_REGEXP) { a = jsP_newstrnode(J, EXP_REGEXP, J->text); a->number = J->number; jsP_next(J); return a; } if (J->lookahead == TK_NUMBER) { a = jsP_newnumnode(J, EXP_NUMBER, J->number); jsP_next(J); return a; } if (jsP_accept(J, TK_THIS)) return EXP0(THIS); if (jsP_accept(J, TK_NULL)) return EXP0(NULL); if (jsP_accept(J, TK_TRUE)) return EXP0(TRUE); if (jsP_accept(J, TK_FALSE)) return EXP0(FALSE); if (jsP_accept(J, '{')) { a = EXP1(OBJECT, objectliteral(J)); jsP_expect(J, '}'); return a; } if (jsP_accept(J, '[')) { a = EXP1(ARRAY, arrayliteral(J)); jsP_expect(J, ']'); return a; } if (jsP_accept(J, '(')) { a = expression(J, 0); jsP_expect(J, ')'); return a; } jsP_error(J, "unexpected token in expression: %s", jsY_tokenstring(J->lookahead)); }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,490
static js_Ast *propassign(js_State *J) { js_Ast *name, *value, *arg, *body; name = propname(J); if (J->lookahead != ':' && name->type == AST_IDENTIFIER) { if (!strcmp(name->string, "get")) { name = propname(J); jsP_expect(J, '('); jsP_expect(J, ')'); body = funbody(J); return EXP3(PROP_GET, name, NULL, body); } if (!strcmp(name->string, "set")) { name = propname(J); jsP_expect(J, '('); arg = identifier(J); jsP_expect(J, ')'); body = funbody(J); return EXP3(PROP_SET, name, LIST(arg), body); } } jsP_expect(J, ':'); value = assignment(J, 0); return EXP2(PROP_VAL, name, value); }
DoS
0
static js_Ast *propassign(js_State *J) { js_Ast *name, *value, *arg, *body; name = propname(J); if (J->lookahead != ':' && name->type == AST_IDENTIFIER) { if (!strcmp(name->string, "get")) { name = propname(J); jsP_expect(J, '('); jsP_expect(J, ')'); body = funbody(J); return EXP3(PROP_GET, name, NULL, body); } if (!strcmp(name->string, "set")) { name = propname(J); jsP_expect(J, '('); arg = identifier(J); jsP_expect(J, ')'); body = funbody(J); return EXP3(PROP_SET, name, LIST(arg), body); } } jsP_expect(J, ':'); value = assignment(J, 0); return EXP2(PROP_VAL, name, value); }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,491
static js_Ast *propname(js_State *J) { js_Ast *name; if (J->lookahead == TK_NUMBER) { name = jsP_newnumnode(J, EXP_NUMBER, J->number); jsP_next(J); } else if (J->lookahead == TK_STRING) { name = jsP_newstrnode(J, EXP_STRING, J->text); jsP_next(J); } else { name = identifiername(J); } return name; }
DoS
0
static js_Ast *propname(js_State *J) { js_Ast *name; if (J->lookahead == TK_NUMBER) { name = jsP_newnumnode(J, EXP_NUMBER, J->number); jsP_next(J); } else if (J->lookahead == TK_STRING) { name = jsP_newstrnode(J, EXP_STRING, J->text); jsP_next(J); } else { name = identifiername(J); } return name; }
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,492
static void semicolon(js_State *J) { if (J->lookahead == ';') { jsP_next(J); return; } if (J->newline || J->lookahead == '}' || J->lookahead == 0)
DoS
0
static void semicolon(js_State *J) { if (J->lookahead == ';') { jsP_next(J); return; } if (J->newline || J->lookahead == '}' || J->lookahead == 0)
@@ -25,6 +25,8 @@ JS_NORETURN static void jsP_error(js_State *J, const char *fmt, ...) JS_PRINTFLI #define INCREC() if (++J->astdepth > JS_ASTLIMIT) jsP_error(J, "too much recursion") #define DECREC() --J->astdepth +#define SAVEREC() int SAVE=J->astdepth +#define POPREC() J->astdepth=SAVE static void jsP_error(js_State *J, const char *fmt, ...) { @@ -383,23 +385,26 @@ static js_Ast *newexp(js_State *J) static js_Ast *memberexp(js_State *J) { - js_Ast *a; - INCREC(); - a = newexp(J); + js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } - DECREC(); + POPREC(); return a; } static js_Ast *callexp(js_State *J) { js_Ast *a = newexp(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '.')) { a = EXP2(MEMBER, a, identifiername(J)); goto loop; } if (jsP_accept(J, '[')) { a = EXP2(INDEX, a, expression(J, 0)); jsP_expect(J, ']'); goto loop; } if (jsP_accept(J, '(')) { a = EXP2(CALL, a, arguments(J)); jsP_expect(J, ')'); goto loop; } + POPREC(); return a; } @@ -432,104 +437,139 @@ static js_Ast *unary(js_State *J) static js_Ast *multiplicative(js_State *J) { js_Ast *a = unary(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '*')) { a = EXP2(MUL, a, unary(J)); goto loop; } if (jsP_accept(J, '/')) { a = EXP2(DIV, a, unary(J)); goto loop; } if (jsP_accept(J, '%')) { a = EXP2(MOD, a, unary(J)); goto loop; } + POPREC(); return a; } static js_Ast *additive(js_State *J) { js_Ast *a = multiplicative(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '+')) { a = EXP2(ADD, a, multiplicative(J)); goto loop; } if (jsP_accept(J, '-')) { a = EXP2(SUB, a, multiplicative(J)); goto loop; } + POPREC(); return a; } static js_Ast *shift(js_State *J) { js_Ast *a = additive(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_SHL)) { a = EXP2(SHL, a, additive(J)); goto loop; } if (jsP_accept(J, TK_SHR)) { a = EXP2(SHR, a, additive(J)); goto loop; } if (jsP_accept(J, TK_USHR)) { a = EXP2(USHR, a, additive(J)); goto loop; } + POPREC(); return a; } static js_Ast *relational(js_State *J, int notin) { js_Ast *a = shift(J); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, '<')) { a = EXP2(LT, a, shift(J)); goto loop; } if (jsP_accept(J, '>')) { a = EXP2(GT, a, shift(J)); goto loop; } if (jsP_accept(J, TK_LE)) { a = EXP2(LE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_GE)) { a = EXP2(GE, a, shift(J)); goto loop; } if (jsP_accept(J, TK_INSTANCEOF)) { a = EXP2(INSTANCEOF, a, shift(J)); goto loop; } if (!notin && jsP_accept(J, TK_IN)) { a = EXP2(IN, a, shift(J)); goto loop; } + POPREC(); return a; } static js_Ast *equality(js_State *J, int notin) { js_Ast *a = relational(J, notin); + SAVEREC(); loop: + INCREC(); if (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; } if (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; } + POPREC(); return a; } static js_Ast *bitand(js_State *J, int notin) { js_Ast *a = equality(J, notin); - while (jsP_accept(J, '&')) + SAVEREC(); + while (jsP_accept(J, '&')) { + INCREC(); a = EXP2(BITAND, a, equality(J, notin)); + } + POPREC(); return a; } static js_Ast *bitxor(js_State *J, int notin) { js_Ast *a = bitand(J, notin); - while (jsP_accept(J, '^')) + SAVEREC(); + while (jsP_accept(J, '^')) { + INCREC(); a = EXP2(BITXOR, a, bitand(J, notin)); + } + POPREC(); return a; } static js_Ast *bitor(js_State *J, int notin) { js_Ast *a = bitxor(J, notin); - while (jsP_accept(J, '|')) + SAVEREC(); + while (jsP_accept(J, '|')) { + INCREC(); a = EXP2(BITOR, a, bitxor(J, notin)); + } + POPREC(); return a; } static js_Ast *logand(js_State *J, int notin) { js_Ast *a = bitor(J, notin); - if (jsP_accept(J, TK_AND)) + if (jsP_accept(J, TK_AND)) { + INCREC(); a = EXP2(LOGAND, a, logand(J, notin)); + DECREC(); + } return a; } static js_Ast *logor(js_State *J, int notin) { js_Ast *a = logand(J, notin); - if (jsP_accept(J, TK_OR)) + if (jsP_accept(J, TK_OR)) { + INCREC(); a = EXP2(LOGOR, a, logor(J, notin)); + DECREC(); + } return a; } static js_Ast *conditional(js_State *J, int notin) { - js_Ast *a, *b, *c; - a = logor(J, notin); + js_Ast *a = logor(J, notin); if (jsP_accept(J, '?')) { + js_Ast *b, *c; + INCREC(); b = assignment(J, 0); jsP_expect(J, ':'); c = assignment(J, notin); + DECREC(); return EXP3(COND, a, b, c); } return a; @@ -537,9 +577,8 @@ static js_Ast *conditional(js_State *J, int notin) static js_Ast *assignment(js_State *J, int notin) { - js_Ast *a; + js_Ast *a = conditional(J, notin); INCREC(); - a = conditional(J, notin); if (jsP_accept(J, '=')) a = EXP2(ASS, a, assignment(J, notin)); else if (jsP_accept(J, TK_MUL_ASS)) a = EXP2(ASS_MUL, a, assignment(J, notin)); else if (jsP_accept(J, TK_DIV_ASS)) a = EXP2(ASS_DIV, a, assignment(J, notin)); @@ -558,12 +597,13 @@ static js_Ast *assignment(js_State *J, int notin) static js_Ast *expression(js_State *J, int notin) { - js_Ast *a; - INCREC(); - a = assignment(J, notin); - while (jsP_accept(J, ',')) + js_Ast *a = assignment(J, notin); + SAVEREC(); + while (jsP_accept(J, ',')) { + INCREC(); a = EXP2(COMMA, a, assignment(J, notin)); - DECREC(); + } + POPREC(); return a; }
CWE-674
null
null
9,493
CMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher) { CMS_ContentInfo *cms; CMS_EnvelopedData *env; cms = CMS_ContentInfo_new(); if (cms == NULL) goto merr; env = cms_enveloped_data_init(cms); if (env == NULL) goto merr; if (!cms_EncryptedContent_init(env->encryptedContentInfo, cipher, NULL, 0)) goto merr; return cms; merr: CMS_ContentInfo_free(cms); CMSerr(CMS_F_CMS_ENVELOPEDDATA_CREATE, ERR_R_MALLOC_FAILURE); return NULL; }
null
0
CMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher) { CMS_ContentInfo *cms; CMS_EnvelopedData *env; cms = CMS_ContentInfo_new(); if (cms == NULL) goto merr; env = cms_enveloped_data_init(cms); if (env == NULL) goto merr; if (!cms_EncryptedContent_init(env->encryptedContentInfo, cipher, NULL, 0)) goto merr; return cms; merr: CMS_ContentInfo_free(cms); CMSerr(CMS_F_CMS_ENVELOPEDDATA_CREATE, ERR_R_MALLOC_FAILURE); return NULL; }
@@ -363,6 +363,7 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, unsigned char *ek = NULL; size_t eklen; int ret = 0; + size_t fixlen = 0; CMS_EncryptedContentInfo *ec; ec = cms->d.envelopedData->encryptedContentInfo; @@ -371,6 +372,19 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, return 0; } + if (cms->d.envelopedData->encryptedContentInfo->havenocert + && !cms->d.envelopedData->encryptedContentInfo->debug) { + X509_ALGOR *calg = ec->contentEncryptionAlgorithm; + const EVP_CIPHER *ciph = EVP_get_cipherbyobj(calg->algorithm); + + if (ciph == NULL) { + CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_UNKNOWN_CIPHER); + return 0; + } + + fixlen = EVP_CIPHER_key_length(ciph); + } + ktri->pctx = EVP_PKEY_CTX_new(pkey, NULL); if (ktri->pctx == NULL) return 0; @@ -401,7 +415,9 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, if (EVP_PKEY_decrypt(ktri->pctx, ek, &eklen, ktri->encryptedKey->data, - ktri->encryptedKey->length) <= 0) { + ktri->encryptedKey->length) <= 0 + || eklen == 0 + || (fixlen != 0 && eklen != fixlen)) { CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_CMS_LIB); goto err; }
CWE-311
null
null
9,494
int CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) { switch (ri->type) { case CMS_RECIPINFO_TRANS: return cms_RecipientInfo_ktri_decrypt(cms, ri); case CMS_RECIPINFO_KEK: return cms_RecipientInfo_kekri_decrypt(cms, ri); case CMS_RECIPINFO_PASS: return cms_RecipientInfo_pwri_crypt(cms, ri, 0); default: CMSerr(CMS_F_CMS_RECIPIENTINFO_DECRYPT, CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE); return 0; } }
null
0
int CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) { switch (ri->type) { case CMS_RECIPINFO_TRANS: return cms_RecipientInfo_ktri_decrypt(cms, ri); case CMS_RECIPINFO_KEK: return cms_RecipientInfo_kekri_decrypt(cms, ri); case CMS_RECIPINFO_PASS: return cms_RecipientInfo_pwri_crypt(cms, ri, 0); default: CMSerr(CMS_F_CMS_RECIPIENTINFO_DECRYPT, CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE); return 0; } }
@@ -363,6 +363,7 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, unsigned char *ek = NULL; size_t eklen; int ret = 0; + size_t fixlen = 0; CMS_EncryptedContentInfo *ec; ec = cms->d.envelopedData->encryptedContentInfo; @@ -371,6 +372,19 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, return 0; } + if (cms->d.envelopedData->encryptedContentInfo->havenocert + && !cms->d.envelopedData->encryptedContentInfo->debug) { + X509_ALGOR *calg = ec->contentEncryptionAlgorithm; + const EVP_CIPHER *ciph = EVP_get_cipherbyobj(calg->algorithm); + + if (ciph == NULL) { + CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_UNKNOWN_CIPHER); + return 0; + } + + fixlen = EVP_CIPHER_key_length(ciph); + } + ktri->pctx = EVP_PKEY_CTX_new(pkey, NULL); if (ktri->pctx == NULL) return 0; @@ -401,7 +415,9 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, if (EVP_PKEY_decrypt(ktri->pctx, ek, &eklen, ktri->encryptedKey->data, - ktri->encryptedKey->length) <= 0) { + ktri->encryptedKey->length) <= 0 + || eklen == 0 + || (fixlen != 0 && eklen != fixlen)) { CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_CMS_LIB); goto err; }
CWE-311
null
null
9,495
int CMS_RecipientInfo_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) { switch (ri->type) { case CMS_RECIPINFO_TRANS: return cms_RecipientInfo_ktri_encrypt(cms, ri); case CMS_RECIPINFO_AGREE: return cms_RecipientInfo_kari_encrypt(cms, ri); case CMS_RECIPINFO_KEK: return cms_RecipientInfo_kekri_encrypt(cms, ri); case CMS_RECIPINFO_PASS: return cms_RecipientInfo_pwri_crypt(cms, ri, 1); default: CMSerr(CMS_F_CMS_RECIPIENTINFO_ENCRYPT, CMS_R_UNSUPPORTED_RECIPIENT_TYPE); return 0; } }
null
0
int CMS_RecipientInfo_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) { switch (ri->type) { case CMS_RECIPINFO_TRANS: return cms_RecipientInfo_ktri_encrypt(cms, ri); case CMS_RECIPINFO_AGREE: return cms_RecipientInfo_kari_encrypt(cms, ri); case CMS_RECIPINFO_KEK: return cms_RecipientInfo_kekri_encrypt(cms, ri); case CMS_RECIPINFO_PASS: return cms_RecipientInfo_pwri_crypt(cms, ri, 1); default: CMSerr(CMS_F_CMS_RECIPIENTINFO_ENCRYPT, CMS_R_UNSUPPORTED_RECIPIENT_TYPE); return 0; } }
@@ -363,6 +363,7 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, unsigned char *ek = NULL; size_t eklen; int ret = 0; + size_t fixlen = 0; CMS_EncryptedContentInfo *ec; ec = cms->d.envelopedData->encryptedContentInfo; @@ -371,6 +372,19 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, return 0; } + if (cms->d.envelopedData->encryptedContentInfo->havenocert + && !cms->d.envelopedData->encryptedContentInfo->debug) { + X509_ALGOR *calg = ec->contentEncryptionAlgorithm; + const EVP_CIPHER *ciph = EVP_get_cipherbyobj(calg->algorithm); + + if (ciph == NULL) { + CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_UNKNOWN_CIPHER); + return 0; + } + + fixlen = EVP_CIPHER_key_length(ciph); + } + ktri->pctx = EVP_PKEY_CTX_new(pkey, NULL); if (ktri->pctx == NULL) return 0; @@ -401,7 +415,9 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, if (EVP_PKEY_decrypt(ktri->pctx, ek, &eklen, ktri->encryptedKey->data, - ktri->encryptedKey->length) <= 0) { + ktri->encryptedKey->length) <= 0 + || eklen == 0 + || (fixlen != 0 && eklen != fixlen)) { CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_CMS_LIB); goto err; }
CWE-311
null
null
9,496
EVP_PKEY_CTX *CMS_RecipientInfo_get0_pkey_ctx(CMS_RecipientInfo *ri) { if (ri->type == CMS_RECIPINFO_TRANS) return ri->d.ktri->pctx; else if (ri->type == CMS_RECIPINFO_AGREE) return ri->d.kari->pctx; return NULL; }
null
0
EVP_PKEY_CTX *CMS_RecipientInfo_get0_pkey_ctx(CMS_RecipientInfo *ri) { if (ri->type == CMS_RECIPINFO_TRANS) return ri->d.ktri->pctx; else if (ri->type == CMS_RECIPINFO_AGREE) return ri->d.kari->pctx; return NULL; }
@@ -363,6 +363,7 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, unsigned char *ek = NULL; size_t eklen; int ret = 0; + size_t fixlen = 0; CMS_EncryptedContentInfo *ec; ec = cms->d.envelopedData->encryptedContentInfo; @@ -371,6 +372,19 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, return 0; } + if (cms->d.envelopedData->encryptedContentInfo->havenocert + && !cms->d.envelopedData->encryptedContentInfo->debug) { + X509_ALGOR *calg = ec->contentEncryptionAlgorithm; + const EVP_CIPHER *ciph = EVP_get_cipherbyobj(calg->algorithm); + + if (ciph == NULL) { + CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_UNKNOWN_CIPHER); + return 0; + } + + fixlen = EVP_CIPHER_key_length(ciph); + } + ktri->pctx = EVP_PKEY_CTX_new(pkey, NULL); if (ktri->pctx == NULL) return 0; @@ -401,7 +415,9 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, if (EVP_PKEY_decrypt(ktri->pctx, ek, &eklen, ktri->encryptedKey->data, - ktri->encryptedKey->length) <= 0) { + ktri->encryptedKey->length) <= 0 + || eklen == 0 + || (fixlen != 0 && eklen != fixlen)) { CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_CMS_LIB); goto err; }
CWE-311
null
null
9,497
int CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri, X509_ALGOR **palg, ASN1_OCTET_STRING **pid, ASN1_GENERALIZEDTIME **pdate, ASN1_OBJECT **potherid, ASN1_TYPE **pothertype) { CMS_KEKIdentifier *rkid; if (ri->type != CMS_RECIPINFO_KEK) { CMSerr(CMS_F_CMS_RECIPIENTINFO_KEKRI_GET0_ID, CMS_R_NOT_KEK); return 0; } rkid = ri->d.kekri->kekid; if (palg) *palg = ri->d.kekri->keyEncryptionAlgorithm; if (pid) *pid = rkid->keyIdentifier; if (pdate) *pdate = rkid->date; if (potherid) { if (rkid->other) *potherid = rkid->other->keyAttrId; else *potherid = NULL; } if (pothertype) { if (rkid->other) *pothertype = rkid->other->keyAttr; else *pothertype = NULL; } return 1; }
null
0
int CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri, X509_ALGOR **palg, ASN1_OCTET_STRING **pid, ASN1_GENERALIZEDTIME **pdate, ASN1_OBJECT **potherid, ASN1_TYPE **pothertype) { CMS_KEKIdentifier *rkid; if (ri->type != CMS_RECIPINFO_KEK) { CMSerr(CMS_F_CMS_RECIPIENTINFO_KEKRI_GET0_ID, CMS_R_NOT_KEK); return 0; } rkid = ri->d.kekri->kekid; if (palg) *palg = ri->d.kekri->keyEncryptionAlgorithm; if (pid) *pid = rkid->keyIdentifier; if (pdate) *pdate = rkid->date; if (potherid) { if (rkid->other) *potherid = rkid->other->keyAttrId; else *potherid = NULL; } if (pothertype) { if (rkid->other) *pothertype = rkid->other->keyAttr; else *pothertype = NULL; } return 1; }
@@ -363,6 +363,7 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, unsigned char *ek = NULL; size_t eklen; int ret = 0; + size_t fixlen = 0; CMS_EncryptedContentInfo *ec; ec = cms->d.envelopedData->encryptedContentInfo; @@ -371,6 +372,19 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, return 0; } + if (cms->d.envelopedData->encryptedContentInfo->havenocert + && !cms->d.envelopedData->encryptedContentInfo->debug) { + X509_ALGOR *calg = ec->contentEncryptionAlgorithm; + const EVP_CIPHER *ciph = EVP_get_cipherbyobj(calg->algorithm); + + if (ciph == NULL) { + CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_UNKNOWN_CIPHER); + return 0; + } + + fixlen = EVP_CIPHER_key_length(ciph); + } + ktri->pctx = EVP_PKEY_CTX_new(pkey, NULL); if (ktri->pctx == NULL) return 0; @@ -401,7 +415,9 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, if (EVP_PKEY_decrypt(ktri->pctx, ek, &eklen, ktri->encryptedKey->data, - ktri->encryptedKey->length) <= 0) { + ktri->encryptedKey->length) <= 0 + || eklen == 0 + || (fixlen != 0 && eklen != fixlen)) { CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_CMS_LIB); goto err; }
CWE-311
null
null
9,498
int CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri, const unsigned char *id, size_t idlen) { ASN1_OCTET_STRING tmp_os; CMS_KEKRecipientInfo *kekri; if (ri->type != CMS_RECIPINFO_KEK) { CMSerr(CMS_F_CMS_RECIPIENTINFO_KEKRI_ID_CMP, CMS_R_NOT_KEK); return -2; } kekri = ri->d.kekri; tmp_os.type = V_ASN1_OCTET_STRING; tmp_os.flags = 0; tmp_os.data = (unsigned char *)id; tmp_os.length = (int)idlen; return ASN1_OCTET_STRING_cmp(&tmp_os, kekri->kekid->keyIdentifier); }
null
0
int CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri, const unsigned char *id, size_t idlen) { ASN1_OCTET_STRING tmp_os; CMS_KEKRecipientInfo *kekri; if (ri->type != CMS_RECIPINFO_KEK) { CMSerr(CMS_F_CMS_RECIPIENTINFO_KEKRI_ID_CMP, CMS_R_NOT_KEK); return -2; } kekri = ri->d.kekri; tmp_os.type = V_ASN1_OCTET_STRING; tmp_os.flags = 0; tmp_os.data = (unsigned char *)id; tmp_os.length = (int)idlen; return ASN1_OCTET_STRING_cmp(&tmp_os, kekri->kekid->keyIdentifier); }
@@ -363,6 +363,7 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, unsigned char *ek = NULL; size_t eklen; int ret = 0; + size_t fixlen = 0; CMS_EncryptedContentInfo *ec; ec = cms->d.envelopedData->encryptedContentInfo; @@ -371,6 +372,19 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, return 0; } + if (cms->d.envelopedData->encryptedContentInfo->havenocert + && !cms->d.envelopedData->encryptedContentInfo->debug) { + X509_ALGOR *calg = ec->contentEncryptionAlgorithm; + const EVP_CIPHER *ciph = EVP_get_cipherbyobj(calg->algorithm); + + if (ciph == NULL) { + CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_UNKNOWN_CIPHER); + return 0; + } + + fixlen = EVP_CIPHER_key_length(ciph); + } + ktri->pctx = EVP_PKEY_CTX_new(pkey, NULL); if (ktri->pctx == NULL) return 0; @@ -401,7 +415,9 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, if (EVP_PKEY_decrypt(ktri->pctx, ek, &eklen, ktri->encryptedKey->data, - ktri->encryptedKey->length) <= 0) { + ktri->encryptedKey->length) <= 0 + || eklen == 0 + || (fixlen != 0 && eklen != fixlen)) { CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_CMS_LIB); goto err; }
CWE-311
null
null
9,499
int CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri, X509 *cert) { if (ri->type != CMS_RECIPINFO_TRANS) { CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_CERT_CMP, CMS_R_NOT_KEY_TRANSPORT); return -2; } return cms_SignerIdentifier_cert_cmp(ri->d.ktri->rid, cert); }
null
0
int CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri, X509 *cert) { if (ri->type != CMS_RECIPINFO_TRANS) { CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_CERT_CMP, CMS_R_NOT_KEY_TRANSPORT); return -2; } return cms_SignerIdentifier_cert_cmp(ri->d.ktri->rid, cert); }
@@ -363,6 +363,7 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, unsigned char *ek = NULL; size_t eklen; int ret = 0; + size_t fixlen = 0; CMS_EncryptedContentInfo *ec; ec = cms->d.envelopedData->encryptedContentInfo; @@ -371,6 +372,19 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, return 0; } + if (cms->d.envelopedData->encryptedContentInfo->havenocert + && !cms->d.envelopedData->encryptedContentInfo->debug) { + X509_ALGOR *calg = ec->contentEncryptionAlgorithm; + const EVP_CIPHER *ciph = EVP_get_cipherbyobj(calg->algorithm); + + if (ciph == NULL) { + CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_UNKNOWN_CIPHER); + return 0; + } + + fixlen = EVP_CIPHER_key_length(ciph); + } + ktri->pctx = EVP_PKEY_CTX_new(pkey, NULL); if (ktri->pctx == NULL) return 0; @@ -401,7 +415,9 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, if (EVP_PKEY_decrypt(ktri->pctx, ek, &eklen, ktri->encryptedKey->data, - ktri->encryptedKey->length) <= 0) { + ktri->encryptedKey->length) <= 0 + || eklen == 0 + || (fixlen != 0 && eklen != fixlen)) { CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_CMS_LIB); goto err; }
CWE-311
null
null