Переглянути джерело

warn and fail if server chose a nickname with illegal characters

svn:r1318
Roger Dingledine 20 роки тому
батько
коміт
568a4e0a04
1 змінених файлів з 9 додано та 3 видалено
  1. 9 3
      src/or/config.c

+ 9 - 3
src/or/config.c

@@ -568,9 +568,15 @@ int getconfig(int argc, char **argv, or_options_t *options) {
     result = -1;
   }
 
-  if(options->ORPort && options->Nickname == NULL) {
-    log_fn(LOG_WARN,"Nickname required if ORPort is set, but not found.");
-    result = -1;
+  if (options->ORPort) {
+    if (options->Nickname == NULL) {
+      log_fn(LOG_WARN,"Nickname required if ORPort is set, but not found.");
+      result = -1;
+    } else if (strspn(options->Nickname, LEGAL_NICKNAME_CHARACTERS) !=
+               strlen(options->Nickname)) {
+      log_fn(LOG_WARN, "Nickname '%s' contains illegal characters.", options->Nickname);
+      result = -1;
+    }
   }
 
   if(options->ORPort) { /* get an IP for ourselves */