/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to plugins.d/mandos-client.c

  • Committer: Teddy Hogeborn
  • Date: 2009-02-12 06:09:24 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090212060924-vwxgitxnwr14w9e4
* mandos (Client.start_checker): Bug fix: Add extra check in case the
                                 checker process completed quickly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#define _GNU_SOURCE             /* TEMP_FAILURE_RETRY(), asprintf() */
37
37
 
38
38
#include <stdio.h>              /* fprintf(), stderr, fwrite(),
39
 
                                   stdout, ferror(), remove() */
 
39
                                   stdout, ferror(), sscanf(),
 
40
                                   remove() */
40
41
#include <stdint.h>             /* uint16_t, uint32_t */
41
42
#include <stddef.h>             /* NULL, size_t, ssize_t */
42
43
#include <stdlib.h>             /* free(), EXIT_SUCCESS, EXIT_FAILURE,
43
 
                                   srand(), strtof() */
 
44
                                   srand() */
44
45
#include <stdbool.h>            /* bool, false, true */
45
46
#include <string.h>             /* memset(), strcmp(), strlen(),
46
47
                                   strerror(), asprintf(), strcpy() */
55
56
#include <fcntl.h>              /* open() */
56
57
#include <dirent.h>             /* opendir(), struct dirent, readdir()
57
58
                                 */
58
 
#include <inttypes.h>           /* PRIu16, PRIdMAX, intmax_t,
59
 
                                   strtoimax() */
 
59
#include <inttypes.h>           /* PRIu16, intmax_t, SCNdMAX */
60
60
#include <assert.h>             /* assert() */
61
61
#include <errno.h>              /* perror(), errno */
62
62
#include <time.h>               /* nanosleep(), time() */
894
894
  int error;
895
895
  int ret;
896
896
  intmax_t tmpmax;
897
 
  char *tmp;
 
897
  int numchars;
898
898
  int exitcode = EXIT_SUCCESS;
899
899
  const char *interface = "eth0";
900
900
  struct ifreq network;
914
914
                         ":!CTYPE-X.509:+CTYPE-OPENPGP" };
915
915
  bool gnutls_initialized = false;
916
916
  bool gpgme_initialized = false;
917
 
  float delay = 2.5f;
918
 
  
 
917
  double delay = 2.5;
 
918
 
919
919
  struct sigaction old_sigterm_action;
920
920
  struct sigaction sigterm_action = { .sa_handler = handle_sigterm };
921
921
  
975
975
        pubkey = arg;
976
976
        break;
977
977
      case 129:                 /* --dh-bits */
978
 
        errno = 0;
979
 
        tmpmax = strtoimax(arg, &tmp, 10);
980
 
        if(errno != 0 or tmp == arg or *tmp != '\0'
981
 
           or tmpmax != (typeof(mc.dh_bits))tmpmax){
 
978
        ret = sscanf(arg, "%" SCNdMAX "%n", &tmpmax, &numchars);
 
979
        if(ret < 1 or tmpmax != (typeof(mc.dh_bits))tmpmax
 
980
           or arg[numchars] != '\0'){
982
981
          fprintf(stderr, "Bad number of DH bits\n");
983
982
          exit(EXIT_FAILURE);
984
983
        }
988
987
        mc.priority = arg;
989
988
        break;
990
989
      case 131:                 /* --delay */
991
 
        errno = 0;
992
 
        delay = strtof(arg, &tmp);
993
 
        if(errno != 0 or tmp == arg or *tmp != '\0'){
 
990
        ret = sscanf(arg, "%lf%n", &delay, &numchars);
 
991
        if(ret < 1 or arg[numchars] != '\0'){
994
992
          fprintf(stderr, "Bad delay\n");
995
993
          exit(EXIT_FAILURE);
996
994
        }
1202
1200
      goto end;
1203
1201
    }
1204
1202
    uint16_t port;
1205
 
    errno = 0;
1206
 
    tmpmax = strtoimax(address+1, &tmp, 10);
1207
 
    if(errno != 0 or tmp == address+1 or *tmp != '\0'
1208
 
       or tmpmax != (uint16_t)tmpmax){
 
1203
    ret = sscanf(address+1, "%" SCNdMAX "%n", &tmpmax, &numchars);
 
1204
    if(ret < 1 or tmpmax != (uint16_t)tmpmax
 
1205
       or address[numchars+1] != '\0'){
1209
1206
      fprintf(stderr, "Bad port number\n");
1210
1207
      exitcode = EXIT_FAILURE;
1211
1208
      goto end;