+2020-12-29 Paul Eggert <eggert@cs.ucla.edu>
+
+ canonicalize: fix size overflow treatment
+ This also has some minor cleanups.
+ * lib/canonicalize-lgpl.c, lib/canonicalize.c: No need to include
+ stddef.h, since the code no longer refers directly to ptrdiff_t.
+ * lib/canonicalize-lgpl.c (realpath_stk):
+ * lib/canonicalize.c (canonicalize_filename_mode_stk):
+ Treat size overflow like other out-of-memory.
+ * lib/canonicalize.c: No need to include stdlib.h, since
+ the code no longer refers to stdlib.h functions (other
+ than those that canonicalize.h must declare).
+ * lib/canonicalize.c (canonicalize_filename_mode_stk):
+ Do not bother terminating the string result on error.
+
2020-12-29 Bruno Haible <bruno@clisp.org>
list-c++, [o]map-c++, [o]set-c++: Fix conflict with 'free-posix' module.
#include <fcntl.h>
#include <limits.h>
#include <stdbool.h>
-#include <stddef.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
end_idx = end - extra_buf;
size_t len = strlen (end);
if (NARROW_ADDRESSES && INT_ADD_OVERFLOW (len, n))
- {
- __set_errno (ENOMEM);
- goto error;
- }
+ goto error_nomem;
while (extra_buffer.length <= len + n)
{
if (!scratch_buffer_grow_preserve (&extra_buffer))
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
-#include <stddef.h>
-#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
end_idx = end - extra_buf;
size_t len = strlen (end);
if (NARROW_ADDRESSES && INT_ADD_OVERFLOW (len, n))
- {
- errno = ENOMEM;
- goto error;
- }
+ xalloc_die ();
while (extra_buffer.length <= len + n)
{
if (!scratch_buffer_grow_preserve (&extra_buffer))
failed = false;
error:
- *dest++ = '\0';
if (ht)
hash_free (ht);
scratch_buffer_free (&extra_buffer);
return NULL;
}
+ *dest++ = '\0';
char *result = scratch_buffer_dupfree (rname_buf, dest - rname);
if (!result)
xalloc_die ();