~ubuntu-branches/ubuntu/jaunty/gxine/jaunty

« back to all changes in this revision

Viewing changes to m4/size_max.m4

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen, SECURITY
  • Date: 2007-01-08 15:13:54 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070108151354-37ypiqavs56365wo
Tags: 0.5.10-0ubuntu1
[SECURITY]: Fix potential buffer overflow leading to segfault or
possible arbitrary code execution.
* New upstream release.
* debian/control: Add libxine1-ffmpeg to build dependencies, fixes
  FTBFS.
* debian/patches/:
  - 04_poke_xscreensaver.dpatch: Remove, upstream has provided similar
    code in 0.5.9,
  - 05_no_splash.dpatch: Rediff,
  - 06_fix_about_dialog.dpatch: Remove, upstream has applied a similar
    fix in 0.5.9.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# size_max.m4 serial 2
2
 
dnl Copyright (C) 2003 Free Software Foundation, Inc.
3
 
dnl This file is free software, distributed under the terms of the GNU
4
 
dnl General Public License.  As a special exception to the GNU General
5
 
dnl Public License, this file may be distributed as part of a program
6
 
dnl that contains a configuration script generated by Autoconf, under
7
 
dnl the same distribution terms as the rest of that program.
 
1
# size_max.m4 serial 4
 
2
dnl Copyright (C) 2003, 2005-2006 Free Software Foundation, Inc.
 
3
dnl This file is free software; the Free Software Foundation
 
4
dnl gives unlimited permission to copy and/or distribute it,
 
5
dnl with or without modifications, as long as this notice is preserved.
8
6
 
9
7
dnl From Bruno Haible.
10
8
 
25
23
], result=yes)
26
24
  if test -z "$result"; then
27
25
    dnl Define it ourselves. Here we assume that the type 'size_t' is not wider
28
 
    dnl than the type 'unsigned long'.
29
 
    dnl The _AC_COMPUTE_INT macro works up to LONG_MAX, since it uses 'expr',
30
 
    dnl which is guaranteed to work from LONG_MIN to LONG_MAX.
31
 
    _AC_COMPUTE_INT([~(size_t)0 / 10], res_hi,
32
 
      [#include <stddef.h>], result=?)
33
 
    _AC_COMPUTE_INT([~(size_t)0 % 10], res_lo,
34
 
      [#include <stddef.h>], result=?)
 
26
    dnl than the type 'unsigned long'. Try hard to find a definition that can
 
27
    dnl be used in a preprocessor #if, i.e. doesn't contain a cast.
 
28
    _AC_COMPUTE_INT([sizeof (size_t) * CHAR_BIT - 1], size_t_bits_minus_1,
 
29
      [#include <stddef.h>
 
30
#include <limits.h>], size_t_bits_minus_1=)
35
31
    _AC_COMPUTE_INT([sizeof (size_t) <= sizeof (unsigned int)], fits_in_uint,
36
 
      [#include <stddef.h>], result=?)
37
 
    if test "$fits_in_uint" = 1; then
38
 
      dnl Even though SIZE_MAX fits in an unsigned int, it must be of type
39
 
      dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'.
40
 
      AC_TRY_COMPILE([#include <stddef.h>
41
 
        extern size_t foo;
42
 
        extern unsigned long foo;
43
 
        ], [], fits_in_uint=0)
44
 
    fi
45
 
    if test -z "$result"; then
46
 
      if test "$fits_in_uint" = 1; then
47
 
        result="$res_hi$res_lo"U
 
32
      [#include <stddef.h>], fits_in_uint=)
 
33
    if test -n "$size_t_bits_minus_1" && test -n "$fits_in_uint"; then
 
34
      if test $fits_in_uint = 1; then
 
35
        dnl Even though SIZE_MAX fits in an unsigned int, it must be of type
 
36
        dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'.
 
37
        AC_TRY_COMPILE([#include <stddef.h>
 
38
          extern size_t foo;
 
39
          extern unsigned long foo;
 
40
          ], [], fits_in_uint=0)
 
41
      fi
 
42
      dnl We cannot use 'expr' to simplify this expression, because 'expr'
 
43
      dnl works only with 'long' integers in the host environment, while we
 
44
      dnl might be cross-compiling from a 32-bit platform to a 64-bit platform.
 
45
      if test $fits_in_uint = 1; then
 
46
        result="(((1U << $size_t_bits_minus_1) - 1) * 2 + 1)"
48
47
      else
49
 
        result="$res_hi$res_lo"UL
 
48
        result="(((1UL << $size_t_bits_minus_1) - 1) * 2 + 1)"
50
49
      fi
51
50
    else
52
51
      dnl Shouldn't happen, but who knows...
53
 
      result='~(size_t)0'
 
52
      result='((size_t)~(size_t)0)'
54
53
    fi
55
54
  fi
56
55
  AC_MSG_RESULT([$result])