This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Implement strlcat [BZ#178]


On 11/24/2015 06:30 AM, Florian Weimer wrote:
+
+  /* The sum cannot wrap around because both strings would be larger
+     than half of the address space, which is not possible due to
+     the restrict qualifier.  */
+  return dest_length + src_length;

This comment assumes that the address space is flat, e.g., that uintptr_t is the same width as size_t. Is this a safe assumption? I can't seem to find that assumption documented anywhere. Anyway, assuming the assumption is safe, I suggest mentioning it here, e.g.:

  /* The sum cannot wrap around because both strings would be larger
     than half of the address space, which is not possible because of
the restrict qualifier and because glibc assumes a flat address space. */

I noticed this assumption while preparing a revision to the proposed strlcpy+strlcat manual entries, and my next proposal will be based on this assumption.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]