~ubuntu-branches/ubuntu/trusty/patch/trusty-security

« back to all changes in this revision

Viewing changes to lib/opendir-safer.c

  • Committer: Package Import Robot
  • Author(s): Christoph Berg
  • Date: 2013-01-03 17:34:45 UTC
  • mto: (6.1.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20130103173445-5vf8qmnfgd7ug67h
Tags: upstream-2.7.1
ImportĀ upstreamĀ versionĀ 2.7.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Invoke opendir, but avoid some glitches.
2
2
 
3
 
   Copyright (C) 2009-2011 Free Software Foundation, Inc.
 
3
   Copyright (C) 2009-2012 Free Software Foundation, Inc.
4
4
 
5
5
   This program is free software: you can redistribute it and/or modify
6
6
   it under the terms of the GNU General Public License as published by
50
50
          int e;
51
51
#if HAVE_FDOPENDIR || GNULIB_FDOPENDIR
52
52
          int f = dup_safer (fd);
53
 
          newdp = fdopendir (f);
54
 
          e = errno;
55
 
          if (! newdp)
56
 
            close (f);
 
53
          if (f < 0)
 
54
            {
 
55
              e = errno;
 
56
              newdp = NULL;
 
57
            }
 
58
          else
 
59
            {
 
60
              newdp = fdopendir (f);
 
61
              e = errno;
 
62
              if (! newdp)
 
63
                close (f);
 
64
            }
57
65
#else /* !FDOPENDIR */
58
66
          newdp = opendir_safer (name);
59
67
          e = errno;