[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Git][xorg-team/lib/libxau][upstream-unstable] 12 commits: XauFileName: reset bsize when malloc failed



Title: GitLab

Timo Aaltonen pushed to branch upstream-unstable at X Strike Force / lib / libxau

Commits:

5 changed files:

Changes:

  • AuDispose.c
    ... ... @@ -34,9 +34,9 @@ void
    34 34
     XauDisposeAuth (Xauth *auth)
    
    35 35
     {
    
    36 36
         if (auth) {
    
    37
    -	if (auth->address) (void) free (auth->address);
    
    38
    -	if (auth->number) (void) free (auth->number);
    
    39
    -	if (auth->name) (void) free (auth->name);
    
    37
    +	free (auth->address);
    
    38
    +	free (auth->number);
    
    39
    +	free (auth->name);
    
    40 40
     	if (auth->data) {
    
    41 41
     	    (void) bzero (auth->data, auth->data_length);
    
    42 42
     	    (void) free (auth->data);
    

  • AuFileName.c
    ... ... @@ -29,6 +29,7 @@ in this Software without prior written authorization from The Open Group.
    29 29
     #endif
    
    30 30
     #include <X11/Xauth.h>
    
    31 31
     #include <X11/Xos.h>
    
    32
    +#include <assert.h>
    
    32 33
     #include <stdlib.h>
    
    33 34
     
    
    34 35
     static char *buf = NULL;
    
    ... ... @@ -66,12 +67,14 @@ XauFileName (void)
    66 67
     	return NULL;
    
    67 68
         }
    
    68 69
         size = strlen (name) + strlen(&slashDotXauthority[1]) + 2;
    
    69
    -    if (size > bsize) {
    
    70
    -	if (buf)
    
    71
    -	    free (buf);
    
    70
    +    if ((size > bsize) || (buf == NULL)) {
    
    71
    +	free (buf);
    
    72
    +        assert(size > 0);
    
    72 73
     	buf = malloc (size);
    
    73
    -	if (!buf)
    
    74
    +	if (!buf) {
    
    75
    +	    bsize = 0;
    
    74 76
     	    return NULL;
    
    77
    +	}
    
    75 78
     
    
    76 79
             if (!atexit_registered) {
    
    77 80
                 atexit(free_filename_buffer);
    
    ... ... @@ -81,6 +84,6 @@ XauFileName (void)
    81 84
     	bsize = size;
    
    82 85
         }
    
    83 86
         snprintf (buf, bsize, "%s%s", name,
    
    84
    -              slashDotXauthority + (name[1] == '\0' ? 1 : 0));
    
    87
    +              slashDotXauthority + (name[0] == '/' && name[1] == '\0' ? 1 : 0));
    
    85 88
         return buf;
    
    86 89
     }

  • AuRead.c
    ... ... @@ -77,25 +77,25 @@ XauReadAuth (FILE *auth_file)
    77 77
         if (read_counted_string (&local.address_length, &local.address, auth_file) == 0)
    
    78 78
     	return NULL;
    
    79 79
         if (read_counted_string (&local.number_length, &local.number, auth_file) == 0) {
    
    80
    -	if (local.address) free (local.address);
    
    80
    +	free (local.address);
    
    81 81
     	return NULL;
    
    82 82
         }
    
    83 83
         if (read_counted_string (&local.name_length, &local.name, auth_file) == 0) {
    
    84
    -	if (local.address) free (local.address);
    
    85
    -	if (local.number) free (local.number);
    
    84
    +	free (local.address);
    
    85
    +	free (local.number);
    
    86 86
     	return NULL;
    
    87 87
         }
    
    88 88
         if (read_counted_string (&local.data_length, &local.data, auth_file) == 0) {
    
    89
    -	if (local.address) free (local.address);
    
    90
    -	if (local.number) free (local.number);
    
    91
    -	if (local.name) free (local.name);
    
    89
    +	free (local.address);
    
    90
    +	free (local.number);
    
    91
    +	free (local.name);
    
    92 92
     	return NULL;
    
    93 93
         }
    
    94 94
         ret = (Xauth *) malloc (sizeof (Xauth));
    
    95 95
         if (!ret) {
    
    96
    -	if (local.address) free (local.address);
    
    97
    -	if (local.number) free (local.number);
    
    98
    -	if (local.name) free (local.name);
    
    96
    +	free (local.address);
    
    97
    +	free (local.number);
    
    98
    +	free (local.name);
    
    99 99
     	if (local.data) {
    
    100 100
     	    bzero (local.data, local.data_length);
    
    101 101
     	    free (local.data);
    

  • autogen.sh
    1 1
     #! /bin/sh
    
    2 2
     
    
    3
    -srcdir=`dirname $0`
    
    3
    +srcdir=`dirname "$0"`
    
    4 4
     test -z "$srcdir" && srcdir=.
    
    5 5
     
    
    6 6
     ORIGDIR=`pwd`
    
    7
    -cd $srcdir
    
    7
    +cd "$srcdir"
    
    8 8
     
    
    9 9
     autoreconf -v --install || exit 1
    
    10
    -cd $ORIGDIR || exit $?
    
    10
    +cd "$ORIGDIR" || exit $?
    
    11
    +
    
    12
    +git config --local --get format.subjectPrefix >/dev/null 2>&1 ||
    
    13
    +    git config --local format.subjectPrefix "PATCH libXau"
    
    11 14
     
    
    12 15
     if test -z "$NOCONFIGURE"; then
    
    13
    -    $srcdir/configure "$@"
    
    16
    +    exec "$srcdir"/configure "$@"
    
    14 17
     fi

  • configure.ac
    ... ... @@ -22,8 +22,8 @@
    22 22
     
    
    23 23
     # Initialize Autoconf
    
    24 24
     AC_PREREQ([2.60])
    
    25
    -AC_INIT([libXau], [1.0.8],
    
    26
    -	[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libXau])
    
    25
    +AC_INIT([libXau], [1.0.9],
    
    26
    +	[https://gitlab.freedesktop.org/xorg/lib/libXau/issues], [libXau])
    
    27 27
     AC_CONFIG_SRCDIR([Makefile.am])
    
    28 28
     AC_CONFIG_HEADERS([config.h])
    
    29 29
     AC_USE_SYSTEM_EXTENSIONS
    


  • Reply to: