From 6f1fe22336d824f58bda6680410a6b1c2a72ea2d Mon Sep 17 00:00:00 2001 From: rm88369 Date: Fri, 26 Oct 2007 02:00:34 -0700 Subject: 6605707 /dev* automap causes root console logins to hang until the NFS mount times out --- usr/src/lib/libdevinfo/devinfo_devperm.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'usr/src') diff --git a/usr/src/lib/libdevinfo/devinfo_devperm.c b/usr/src/lib/libdevinfo/devinfo_devperm.c index 2b10a90ba3..3f7380a2de 100644 --- a/usr/src/lib/libdevinfo/devinfo_devperm.c +++ b/usr/src/lib/libdevinfo/devinfo_devperm.c @@ -446,20 +446,24 @@ dir_dev_acc(char *path, char *left_to_do, uid_t uid, gid_t gid, mode_t mode, finddev_close(handle); return (-1); } - match = (char *)calloc(MAXPATHLEN, 1); + match = (char *)calloc(MAXPATHLEN + 2, 1); if (match == NULL) { finddev_close(handle); free(newpath); return (-1); } - if (p) { - (void) strncpy(match, left_to_do, p - left_to_do); - } else { - (void) strcpy(match, left_to_do); + /* transform pattern into ^pattern$ for exact match */ + if (snprintf(match, MAXPATHLEN + 2, "^%.*s$", + p ? (p - left_to_do) : strlen(left_to_do), left_to_do) >= + MAXPATHLEN + 2) { + finddev_close(handle); + free(newpath); + free(match); + return (-1); } - if (strcmp(match, "*") == 0) { + if (strcmp(match, "^*$") == 0) { alwaysmatch = 1; } else { if (regcomp(®ex, match, REG_EXTENDED) != 0) { -- cgit v1.2.3