make publickeydir actually accepting only .pub as suffix
authorGiovanni Giacobbi <johnny@silcnet.org>
Sat, 30 Nov 2002 17:51:33 +0000 (17:51 +0000)
committerGiovanni Giacobbi <johnny@silcnet.org>
Sat, 30 Nov 2002 17:51:33 +0000 (17:51 +0000)
apps/silcd/serverconfig.c

index d40958746709ed5422947e0da0578ceb4d39ed52..b25f4e9437c5318b83c4402d1cc3104ef5d465f4 100644 (file)
@@ -187,14 +187,14 @@ 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[1024];
     const char *filename = get_file->d_name;
+    char buf[1024];
+    int dirname_len = strlen(dirname), filename_len = strlen(filename);
     struct stat check_file;
 
     /* Ignore "." and "..", and take files only with ".pub" suffix. */
     if (!strcmp(filename, ".") || !strcmp(filename, "..") ||
-       !strstr(filename, ".pub"))
+       (filename_len < 5) || strcmp(filename + filename_len - 4, ".pub"))
       continue;
 
     memset(buf, 0, sizeof(buf));