Take only files with .pub suffix in PublicKeyDir.
authorPekka Riikonen <priikone@silcnet.org>
Sat, 30 Nov 2002 14:02:41 +0000 (14:02 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sat, 30 Nov 2002 14:02:41 +0000 (14:02 +0000)
CHANGES
apps/silcd/serverconfig.c

diff --git a/CHANGES b/CHANGES
index 0cc469149629b3bea434ea48b2e903790545e638..246834d117ac0768f76f6fd869f05e40486b9dfd 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+Sat Nov 30 19:07:52 EET 2002  Pekka Riikonen <priikone@silcnet.org>
+
+       * Load only files with .pub suffix in PublicKeyDir.  Affected
+         file silcd/serverconfig.c.
+
 Sat Nov 30 14:29:34 CET 2002  Johnny Mnemonic <johnny@themnemonic.org>
 
        * Extended the SILC_SERVER_LOG_ERROR macro to all available logging
index 05a08dcb64fe16d719b926011325c2598df98bde..d40958746709ed5422947e0da0578ceb4d39ed52 100644 (file)
@@ -188,22 +188,23 @@ static bool my_parse_publickeydir(const char *dirname, void **auth_data)
   /* errors are not considered fatal */
   while ((get_file = readdir(dp))) {
     int dirname_len = strlen(dirname);
-    char buf[1023];
+    char buf[1024];
     const char *filename = get_file->d_name;
     struct stat check_file;
 
-    if (!strcmp(filename, ".") || !strcmp(filename, ".."))
+    /* Ignore "." and "..", and take files only with ".pub" suffix. */
+    if (!strcmp(filename, ".") || !strcmp(filename, "..") ||
+       !strstr(filename, ".pub"))
       continue;
 
-    snprintf(buf, sizeof(buf) - 2, "%s%s%s", dirname,
+    memset(buf, 0, sizeof(buf));
+    snprintf(buf, sizeof(buf) - 1, "%s%s%s", dirname,
             (dirname[dirname_len - 1] == '/' ? "" : "/"), filename);
-    buf[sizeof(buf) - 1] = 0;
 
     if (stat(buf, &check_file) < 0) {
       SILC_SERVER_LOG_ERROR(("Error stating file %s: %s", buf,
                             strerror(errno)));
-    }
-    else if (S_ISREG(check_file.st_mode)) {
+    } else if (S_ISREG(check_file.st_mode)) {
       my_parse_authdata(SILC_AUTH_PUBLIC_KEY, buf, auth_data, NULL);
       total++;
     }