bug-gnustep
[Top][All Lists]
Advanced

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

[bug #35669] Garbage description string in POSIX NSErrors


From: Jens Alfke
Subject: [bug #35669] Garbage description string in POSIX NSErrors
Date: Wed, 29 Feb 2012 19:42:48 +0000
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.22 (KHTML, like Gecko) Chrome/19.0.1049.3 Safari/535.22

URL:
  <http://savannah.gnu.org/bugs/?35669>

                 Summary: Garbage description string in POSIX NSErrors
                 Project: GNUstep
            Submitted by: snej
            Submitted on: Wed 29 Feb 2012 07:42:47 PM GMT
                Category: Base/Foundation
                Severity: 3 - Normal
              Item Group: Bug
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

I am getting NSErrors with garbage description strings back from
NSFileManager. (To be clear: the error is expected, and the domain and code
are correct, but the description string in the userInfo is a large block of
garbage.)

The cause appears to be a bug in +[NSError _lastError] in
NSError+GNUstepBase.m. It calls strerror_r to get an error message, but that
call isn’t filling in the char[] buffer.

Reading the man page tells me that there are two versions of strerror_r (a GNU
one and a POSIX one) with different return types — the GNU version returns
the string its return value and doesn’t always copy it into the buffer. What
seems to be happening is that the method thinks it’s calling the POSIX
version, but it’s actually calling the GNU version. So the error message in
the return value is ignored, and instead it uses the buffer which wasn’t
initialized.

I’m not sure what the best way is to fix this. It looks like one could
either add
        #undef _GNU_SOURCE
near the top of the file where it defines _XOPEN_SOURCE; or one could use an
#if around the call to strerror_r to call either version depending on which
one is available.

I have experimentally tried the latter, adding code that uses the non-POSIX
version of strerror_r, and that fixes the problem.

CONFIGURATION

URL: http://svn.gna.org/svn/gnustep/libs/base/trunk/Source
Repository Root: http://svn.gna.org/svn/gnustep
Repository UUID: 72102866-910b-0410-8b05-ffd578937521
Revision: 34837

My OS is Ubuntu 11 (current according to software update).
I'm compiling with Clang 3.1 (trunk 151546).




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?35669>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]