Use unlinkat() when removing the contents of a directory so we don't
authormillert <millert@openbsd.org>
Mon, 12 Jun 2017 18:56:13 +0000 (18:56 +0000)
committermillert <millert@openbsd.org>
Mon, 12 Jun 2017 18:56:13 +0000 (18:56 +0000)
need to construct paths.  OK deraadt@

usr.sbin/ypbind/ypbind.c

index 34bb8f9..7b1a85c 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ypbind.c,v 1.69 2017/02/17 16:46:17 ajacoutot Exp $ */
+/*     $OpenBSD: ypbind.c,v 1.70 2017/06/12 18:56:13 millert Exp $ */
 
 /*
  * Copyright (c) 1992, 1993, 1996, 1997, 1998 Theo de Raadt <deraadt@openbsd.org>
@@ -369,9 +369,7 @@ main(int argc, char *argv[])
                        if (!strcmp(dent->d_name, ".") ||
                            !strcmp(dent->d_name, ".."))
                                continue;
-                       snprintf(path, sizeof(path), "%s/%s", BINDINGDIR,
-                           dent->d_name);
-                       (void) unlink(path);
+                       (void)unlinkat(dirfd(dirp), dent->d_name, 0);
                }
                closedir(dirp);
        } else {