From 1d51ceb292ad88c1cd36125f743304b63f08e9f0 Mon Sep 17 00:00:00 2001 From: imp Date: Thu, 26 Oct 2000 19:45:42 +0000 Subject: [PATCH] Change snprintf to strncpy. Also add a comment about a bogus assumption in the current code found at bsdcon by jhb. --- sys/pccard/pccard.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/pccard/pccard.c b/sys/pccard/pccard.c index ca573defb63..f3d20dc279d 100644 --- a/sys/pccard/pccard.c +++ b/sys/pccard/pccard.c @@ -255,8 +255,15 @@ allocate_driver(struct slot *slt, struct dev_desc *desc) goto err; } err = device_probe_and_attach(child); - snprintf(desc->name, sizeof(desc->name), "%s", - device_get_nameunit(child)); + /* + * XXX We unwisely assume that the detach code won't run while the + * XXX the attach code is attaching. Someone should put some + * XXX interlock code. This can happen if probe/attach takes a while + * XXX and the user ejects the card, which causes the detach + * XXX function to be called. + */ + strncpy(desc->name, device_get_nameunit(child), sizeof(desc->name)); + desc->name[sizeof(desc->name) - 1] = '\0'; err: if (err) device_delete_child(pccarddev, child); -- 2.45.2