using secure functions safe_strdup

Signed-off-by: luokai <l18674732394.com>
This commit is contained in:
luokai 2021-06-15 11:27:29 +08:00
parent 9cd6f3c5b8
commit 87447a0ee9
6 changed files with 8 additions and 8 deletions

View file

@ -139,7 +139,7 @@ path_seat_get_for_device(struct path_input *input,
seat_logical_name = safe_strdup(seat_logical_name_override);
} else {
seat_prop = udev_device_get_property_value(udev_device, "WL_SEAT");
seat_logical_name = strdup(seat_prop ? seat_prop : default_seat_name);
seat_logical_name = safe_strdup(seat_prop ? seat_prop : default_seat_name);
}
if (!seat_logical_name) {

View file

@ -474,7 +474,7 @@ out:
uint32_t
parse_evdev_abs_prop(const char *prop, struct input_absinfo *abs)
{
char *str = strdup(prop);
char *str = safe_strdup(prop);
char *current, *next;
uint32_t mask = 0;
int bit = ABS_MASK_MIN;

View file

@ -228,11 +228,11 @@ trunkname(const char *filename)
char *suffix;
if (base == NULL)
return strdup("");
return safe_strdup("");
suffix = rindex(base, '.');
if (suffix == NULL)
return strdup(base);
return safe_strdup(base);
else
return strndup(base, suffix-base);
}

View file

@ -1566,7 +1566,7 @@ mkdir_p(const char *dir)
if (streq(dir, "/"))
return;
path = strdup(dir);
path = safe_strdup(dir);
parent = dirname(path);
mkdir_p(parent);

View file

@ -1986,7 +1986,7 @@ init_output_file(const char *file, bool is_prefix)
snprintf(name, sizeof(name), "%s", file);
}
return strdup(name);
return safe_strdup(name);
}
static bool
@ -2509,7 +2509,7 @@ init_hidraw(struct record_context *ctx)
hidraw = zalloc(sizeof(*hidraw));
hidraw->fd = fd;
hidraw->name = strdup(entry->d_name);
hidraw->name = safe_strdup(entry->d_name);
hidraw->device = dev;
list_insert(&dev->hidraw_devices, &hidraw->link);
}

View file

@ -139,7 +139,7 @@ wacom_handle_ekr(struct udev_device *device,
best_dist = dist;
free(*phys_attr);
*phys_attr = strdup(phys);
*phys_attr = safe_strdup(phys);
}
}