/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/plymouth.c

  • Committer: teddy at recompile
  • Date: 2020-03-14 03:22:36 UTC
  • Revision ID: teddy@recompile.se-20200314032236-ea0oko1tlyuzyzye
dracut-module/password-agent.c: Skip flaky test on non-AMD64

It is difficult to find a suitable buffer size large enough to
predictably make send() fail with EMSGSIZE on a PF_LOCAL socket, while
still being small enough to reliably malloc() twice on any platform
and in any environment.  The existing size was experimentally
determined on AMD64; skip the test for all other platforms.

* dracut-module/password-agent.c
  (test_send_password_to_socket_EMSGSIZE): Skip this test on non-AMD64
  platforms.

Closes: 953799
Reported-by: Michael Biebl <biebl@debian.org>

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
                                   STDERR_FILENO, execv(), access() */
45
45
#include <stdlib.h>             /* free(), EXIT_FAILURE, realloc(),
46
46
                                   EXIT_SUCCESS, malloc(), _exit(),
47
 
                                   getenv() */
 
47
                                   getenv(), reallocarray() */
48
48
#include <dirent.h>             /* scandir(), alphasort() */
49
49
#include <inttypes.h>           /* intmax_t, strtoumax(), SCNuMAX */
50
50
#include <sys/stat.h>           /* struct stat, lstat() */
204
204
    char **tmp;
205
205
    int i = 0;
206
206
    for (; argv[i] != NULL; i++){
207
 
      tmp = realloc(new_argv, sizeof(const char *) * ((size_t)i + 2));
 
207
#if defined(__GLIBC_PREREQ) and __GLIBC_PREREQ(2, 26)
 
208
      tmp = reallocarray(new_argv, ((size_t)i + 2),
 
209
                         sizeof(const char *));
 
210
#else
 
211
      if(((size_t)i + 2) > (SIZE_MAX / sizeof(const char *))){
 
212
        /* overflow */
 
213
        tmp = NULL;
 
214
        errno = ENOMEM;
 
215
      } else {
 
216
        tmp = realloc(new_argv, ((size_t)i + 2) * sizeof(const char *));
 
217
      }
 
218
#endif
208
219
      if(tmp == NULL){
209
 
        error_plus(0, errno, "realloc");
 
220
        error_plus(0, errno, "reallocarray");
210
221
        free(new_argv);
211
222
        _exit(EX_OSERR);
212
223
      }