/mandos/release

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

« back to all changes in this revision

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

  • Committer: Teddy Hogeborn
  • Date: 2016-02-21 12:55:39 UTC
  • mto: (237.7.594 trunk)
  • mto: This revision was merged to the branch mainline in revision 331.
  • Revision ID: teddy@recompile.se-20160221125539-wi1n8ci0ldbdxrar
plugins.d/mandos-client.c (get_flags): Use strncpy(), not strcpy().

* plugins.d/mandos-client.c (get_flags): Use strncpy() instead of
  strcpy().  Note that as the code works currently, this is never a
  problem in practice, since only interface names which were valid
  existing interface names (and therefore had names with lengths below
  IF_NAMESIZE) is ever passed to the get_flags() function.  But it
  doesn't hurt to check, anyway.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
 * "browse_callback", and parts of "main".
10
10
 * 
11
11
 * Everything else is
12
 
 * Copyright © 2008-2016 Teddy Hogeborn
13
 
 * Copyright © 2008-2016 Björn Påhlsson
 
12
 * Copyright © 2008-2015 Teddy Hogeborn
 
13
 * Copyright © 2008-2015 Björn Påhlsson
14
14
 * 
15
15
 * This program is free software: you can redistribute it and/or
16
16
 * modify it under the terms of the GNU General Public License as
513
513
  fprintf_plus(stderr, "GnuTLS: %s", string);
514
514
}
515
515
 
516
 
__attribute__((nonnull(1, 2, 4), warn_unused_result))
 
516
__attribute__((nonnull, warn_unused_result))
517
517
static int init_gnutls_global(const char *pubkeyfilename,
518
518
                              const char *seckeyfilename,
519
519
                              const char *dhparamsfilename,
525
525
    fprintf_plus(stderr, "Initializing GnuTLS\n");
526
526
  }
527
527
  
 
528
  ret = gnutls_global_init();
 
529
  if(ret != GNUTLS_E_SUCCESS){
 
530
    fprintf_plus(stderr, "GnuTLS global_init: %s\n",
 
531
                 safer_gnutls_strerror(ret));
 
532
    return -1;
 
533
  }
 
534
  
528
535
  if(debug){
529
536
    /* "Use a log level over 10 to enable all debugging options."
530
537
     * - GnuTLS manual
538
545
  if(ret != GNUTLS_E_SUCCESS){
539
546
    fprintf_plus(stderr, "GnuTLS memory error: %s\n",
540
547
                 safer_gnutls_strerror(ret));
 
548
    gnutls_global_deinit();
541
549
    return -1;
542
550
  }
543
551
  
747
755
 globalfail:
748
756
  
749
757
  gnutls_certificate_free_credentials(mc->cred);
 
758
  gnutls_global_deinit();
750
759
  gnutls_dh_params_deinit(mc->dh_params);
751
760
  return -1;
752
761
}
1905
1914
      return;
1906
1915
    }
1907
1916
  }
 
1917
#ifdef __GLIBC__
 
1918
#if __GLIBC_PREREQ(2, 15)
1908
1919
  int numhooks = scandirat(hookdir_fd, ".", &direntries,
1909
1920
                           runnable_hook, alphasort);
 
1921
#else  /* not __GLIBC_PREREQ(2, 15) */
 
1922
  int numhooks = scandir(hookdir, &direntries, runnable_hook,
 
1923
                         alphasort);
 
1924
#endif  /* not __GLIBC_PREREQ(2, 15) */
 
1925
#else   /* not __GLIBC__ */
 
1926
  int numhooks = scandir(hookdir, &direntries, runnable_hook,
 
1927
                         alphasort);
 
1928
#endif  /* not __GLIBC__ */
1910
1929
  if(numhooks == -1){
1911
1930
    perror_plus("scandir");
1912
1931
    return;
2957
2976
  
2958
2977
  if(gnutls_initialized){
2959
2978
    gnutls_certificate_free_credentials(mc.cred);
 
2979
    gnutls_global_deinit();
2960
2980
    gnutls_dh_params_deinit(mc.dh_params);
2961
2981
  }
2962
2982
  
3034
3054
    if(tempdir_fd == -1){
3035
3055
      perror_plus("open");
3036
3056
    } else {
 
3057
#ifdef __GLIBC__
 
3058
#if __GLIBC_PREREQ(2, 15)
3037
3059
      int numentries = scandirat(tempdir_fd, ".", &direntries,
3038
3060
                                 notdotentries, alphasort);
 
3061
#else  /* not __GLIBC_PREREQ(2, 15) */
 
3062
      int numentries = scandir(tempdir, &direntries, notdotentries,
 
3063
                               alphasort);
 
3064
#endif  /* not __GLIBC_PREREQ(2, 15) */
 
3065
#else   /* not __GLIBC__ */
 
3066
      int numentries = scandir(tempdir, &direntries, notdotentries,
 
3067
                               alphasort);
 
3068
#endif  /* not __GLIBC__ */
3039
3069
      if(numentries >= 0){
3040
3070
        for(int i = 0; i < numentries; i++){
3041
3071
          ret = unlinkat(tempdir_fd, direntries[i]->d_name, 0);