Bug 14176 - mblen is erroneously marked warn_unused_result
Summary: mblen is erroneously marked warn_unused_result
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.13
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-29 19:33 UTC by Antti-Juhani Kaijanaho
Modified: 2019-05-03 07:47 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Antti-Juhani Kaijanaho 2012-05-29 19:33:16 UTC
GCC documentation states:

  The warn_unused_result attribute causes a warning to be emitted if a caller
  of the function with this attribute does not use its return value. This is
  useful for functions where not checking the result is either a security
  problem or always a bug, such as realloc.

However, so far as I can see, ignoring the return value of mblen is never a
security problem and is sometimes appropriate (the first call to the function
is often mblen(NULL, 0), the result value of which is usually of no interest).

(This is also reported as Debian #674917, see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=674917.  The Debian report logs include a patch, not by me.)
Comment 1 Ondrej Bilka 2012-12-19 12:50:29 UTC
Same argument also applies for mbtowc and wctomb. Is this ok?

index fc83f4e..2153bc6 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -856,14 +856,14 @@ extern int qfcvt_r (long double __value, int __ndigit,
 __BEGIN_NAMESPACE_STD
 /* Return the length of the multibyte character
    in S, which is no longer than N.  */
-extern int mblen (const char *__s, size_t __n) __THROW __wur;
+extern int mblen (const char *__s, size_t __n) __THROW;
 /* Return the length of the given multibyte character,
    putting its `wchar_t' representation in *PWC.  */
 extern int mbtowc (wchar_t *__restrict __pwc,
-                  const char *__restrict __s, size_t __n) __THROW __wur;
+                  const char *__restrict __s, size_t __n) __THROW;
 /* Put the multibyte character represented
    by WCHAR in S, returning its length.  */
-extern int wctomb (char *__s, wchar_t __wchar) __THROW __wur;
+extern int wctomb (char *__s, wchar_t __wchar) __THROW;
Comment 2 OndrejBilka 2013-03-20 08:03:45 UTC
Fixed on master.