/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: 2016-02-21 14:24:01 UTC
  • Revision ID: teddy@recompile.se-20160221142401-j7glu6a2hg604d1e
Use AddressSanitizer and UndefinedBehaviorSanitizer.

* Makefile (SANITIZE): New; set to all sanitizing options depending on
                       GCC version.
  (CFLAGS): Added "$(SANITIZE)".

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
                                   strtof(), abort() */
48
48
#include <stdbool.h>            /* bool, false, true */
49
49
#include <string.h>             /* strcmp(), strlen(), strerror(),
50
 
                                   asprintf(), strcpy() */
 
50
                                   asprintf(), strncpy() */
51
51
#include <sys/ioctl.h>          /* ioctl */
52
52
#include <sys/types.h>          /* socket(), inet_pton(), sockaddr,
53
53
                                   sockaddr_in6, PF_INET6,
954
954
                                                   helper, O_RDONLY));
955
955
    if(helper_fd == -1){
956
956
      perror_plus("openat");
 
957
      close(helperdir_fd);
957
958
      _exit(EX_UNAVAILABLE);
958
959
    }
959
960
    close(helperdir_fd);
1222
1223
                    sizeof(struct sockaddr_in));
1223
1224
    }
1224
1225
    if(ret < 0){
1225
 
      if(errno == ENETUNREACH
 
1226
      if(((errno == ENETUNREACH) or (errno == EHOSTUNREACH))
1226
1227
         and if_index != AVAHI_IF_UNSPEC
1227
1228
         and connect_to == NULL
1228
1229
         and not route_added and
1636
1637
    errno = ret_errno;
1637
1638
    return false;
1638
1639
  }
1639
 
  strcpy(ifr->ifr_name, ifname);
 
1640
  strncpy(ifr->ifr_name, ifname, IF_NAMESIZE);
 
1641
  ifr->ifr_name[IF_NAMESIZE-1] = '\0'; /* NUL terminate */
1640
1642
  ret = ioctl(s, SIOCGIFFLAGS, ifr);
1641
1643
  if(ret == -1){
1642
1644
    if(debug){
2287
2289
 
2288
2290
int main(int argc, char *argv[]){
2289
2291
  mandos_context mc = { .server = NULL, .dh_bits = 0,
2290
 
                        .priority = "SECURE256:!CTYPE-X.509:"
2291
 
                        "+CTYPE-OPENPGP:!RSA", .current_server = NULL,
2292
 
                        .interfaces = NULL, .interfaces_size = 0 };
 
2292
                        .priority = "SECURE256:!CTYPE-X.509"
 
2293
                        ":+CTYPE-OPENPGP:!RSA:+SIGN-DSA-SHA256",
 
2294
                        .current_server = NULL, .interfaces = NULL,
 
2295
                        .interfaces_size = 0 };
2293
2296
  AvahiSServiceBrowser *sb = NULL;
2294
2297
  error_t ret_errno;
2295
2298
  int ret;
2547
2550
        }
2548
2551
      }
2549
2552
      
2550
 
      if(strcmp(dh_params_file, PATHDIR "/dhparams.pem" ) == 0){
 
2553
      if(dh_params_file != NULL
 
2554
         and strcmp(dh_params_file, PATHDIR "/dhparams.pem" ) == 0){
2551
2555
        int dhparams_fd = open(dh_params_file, O_RDONLY);
2552
2556
        if(dhparams_fd == -1){
2553
2557
          perror_plus("open");