Browse Source

A few corrections

Use char instead of char* for the single character and don't do this
weird casting thing where a char gets stored in the pointer.
tags/1.3
Timo Röhling 9 years ago
parent
commit
8653cca9b1
1 changed files with 11 additions and 6 deletions
  1. 11
    6
      postsrsd.c

+ 11
- 6
postsrsd.c View File

240
   int opt, timeout = 1800, family = AF_INET;
240
   int opt, timeout = 1800, family = AF_INET;
241
   int daemonize = FALSE;
241
   int daemonize = FALSE;
242
   char *forward_service = NULL, *reverse_service = NULL,
242
   char *forward_service = NULL, *reverse_service = NULL,
243
-       *user = NULL, *domain = NULL, *chroot_dir = NULL, separator = NULL;
243
+       *user = NULL, *domain = NULL, *chroot_dir = NULL;
244
+  char separator = '=';
244
   int forward_sock, reverse_sock;
245
   int forward_sock, reverse_sock;
245
   char *secret_file = NULL, *pid_file = NULL;
246
   char *secret_file = NULL, *pid_file = NULL;
246
   FILE *pf = NULL, *sf = NULL;
247
   FILE *pf = NULL, *sf = NULL;
272
         domain = strdup(optarg);
273
         domain = strdup(optarg);
273
         break;
274
         break;
274
       case 'a':
275
       case 'a':
275
-        separator = (char)*optarg;
276
+        separator = *optarg;
276
         break;
277
         break;
277
       case 'f':
278
       case 'f':
278
         forward_service = strdup(optarg);
279
         forward_service = strdup(optarg);
323
         if ( getenv("SRS_DOMAIN") != NULL )
324
         if ( getenv("SRS_DOMAIN") != NULL )
324
           domain = strdup(getenv("SRS_DOMAIN"));
325
           domain = strdup(getenv("SRS_DOMAIN"));
325
         if ( getenv("SRS_SEPARATOR") != NULL )
326
         if ( getenv("SRS_SEPARATOR") != NULL )
326
-          separator = (char)*getenv("SRS_SEPARATOR");
327
+          separator = *getenv("SRS_SEPARATOR");
327
         if ( getenv("SRS_FORWARD_PORT") != NULL )
328
         if ( getenv("SRS_FORWARD_PORT") != NULL )
328
           forward_service = strdup(getenv("SRS_FORWARD_PORT"));
329
           forward_service = strdup(getenv("SRS_FORWARD_PORT"));
329
         if ( getenv("SRS_REVERSE_PORT") != NULL )
330
         if ( getenv("SRS_REVERSE_PORT") != NULL )
369
     return EXIT_FAILURE;
370
     return EXIT_FAILURE;
370
   }
371
   }
371
 
372
 
373
+  if (separator != '=' && separator != '+' && separator != '-') {
374
+    fprintf (stderr, "%s: SRS separator character must be one of '=+-'\n", self);
375
+    return EXIT_FAILURE;
376
+  }
377
+
372
   /* The stuff we do first may not be possible from within chroot or without privileges */
378
   /* The stuff we do first may not be possible from within chroot or without privileges */
373
 
379
 
374
   /* Open pid file for writing (the actual process ID is filled in later) */
380
   /* Open pid file for writing (the actual process ID is filled in later) */
461
       srs_add_secret (srs, secret);
467
       srs_add_secret (srs, secret);
462
   }
468
   }
463
   fclose (sf);
469
   fclose (sf);
464
-  if (separator && srs_set_separator (srs, separator) != SRS_SUCCESS) {
465
-    srs_set_separator (srs, '=');
466
-  }
470
+
471
+  srs_set_separator (srs, separator);
467
 
472
 
468
   fds[0].fd = forward_sock;
473
   fds[0].fd = forward_sock;
469
   fds[0].events = POLLIN;
474
   fds[0].events = POLLIN;

Loading…
Cancel
Save