nuttx/libs/libc
Karel Kočí f2fd0bc148 libs/libc/obstack: revert invalid null byte append to obstack_vprintf
The commit c4d8d937d5 added null byte for
obstack_vprintf and thus to obstack_printf. I probably lost my marbles
but the same test I run previously now won't append null byte at the end
and this "fix" now causes regressions in code using obstack.

For the reference this is the testing code:

  #define _GNU_SOURCE
  #include <obstack.h>
  #include <stdarg.h>
  #include <stdio.h>
  #include <stdlib.h>

  #define obstack_chunk_alloc malloc
  #define obstack_chunk_free free

  static void print(struct obstack *obs, const char *fmt, ...) {
    va_list arg;
    va_start(arg, fmt);
    obstack_vprintf(obs, fmt, arg);
    va_end(arg);
  }

  int main(int argc, char *argv[]) {
    struct obstack obs;
    obstack_init(&obs);

    obstack_printf(&obs, "this %s", "text ");
    obstack_printf(&obs, "is appended");
    print(&obs, " as well as %s", "vprintf text");
    obstack_1grow(&obs, '\0');

    printf("%s\n", (char *)obstack_finish(&obs));

    obstack_free(&obs, NULL);
    return 0;
  }

The output on NuttX without this patch:

  > obstest
  this text

The output on NuttX with this patch:

  > obstest
  this text is appended as well as vprintf text

The output with GlibC:

  $ gcc test.c && ./a.out
  this text is appended as well as vprintf text
  $ ldd a.out
  	linux-vdso.so.1 (0x00007ffff7fc5000)
  	libc.so.6 => /nix/store/3dyw8dzj9ab4m8hv5dpyx7zii8d0w6fi-glibc-2.39-52/lib/libc.so.6 (0x00007ffff7dc8000)
  	/nix/store/3dyw8dzj9ab4m8hv5dpyx7zii8d0w6fi-glibc-2.39-52/lib/ld-linux-x86-64.so.2 => /nix/store/3dyw8dzj9ab4m8hv5dpyx7zii8d0w6fi-glibc-2.39-52/lib64/ld-linux-x86-64.so.2 (0x00007ffff7fc7000)

The output with Musl (and obstack_vprintf removed):

  $ gcc -lobstack test-musl.c && ./a.out
  this text is appended
  $ ldd a.out
  	/nix/store/00w9nz0343pxk7hbsjzq9bzaby65hk4g-musl-1.2.3/lib/ld-musl-x86_64.so.1 (0x7ffff7f4b000)
  	libobstack.so.1 => /nix/store/qvv16dqn85qwz9vz9wvpnv435z0n5msr-musl-obstack-1.2.3/lib/libobstack.so.1 (0x7ffff7f3b000)
  	libc.so => /nix/store/00w9nz0343pxk7hbsjzq9bzaby65hk4g-musl-1.2.3/lib/ld-musl-x86_64.so.1 (0x7ffff7f4b000)
2024-09-17 11:32:48 +08:00
..
aio
assert greenhills: fix the no-lto link warning 2024-08-24 18:57:40 +08:00
audio
bin
builtin
ctype
dirent nuttx: fix multiple 'FAR', 'CODE' and style issues 2024-08-25 19:22:15 +08:00
dlfcn dlfcn: Fix indent issue in lib_dlopen.c 2024-07-27 03:11:39 +08:00
errno
eventfd
fdt
fixedmath
gdbstub arch: use up_current_regs/up_set_current_regs replace CURRENT_REGS 2024-09-13 23:18:58 +08:00
gpsutils
grp
hex2bin
inttypes nuttx: fix multiple 'FAR', 'CODE' and style issues 2024-08-25 19:22:15 +08:00
kbin
libgen basename: return path address instead of "/" when path="/" 2024-08-22 01:50:37 +08:00
locale nuttx: fix multiple 'FAR', 'CODE' and style issues 2024-08-25 19:22:15 +08:00
lzf nuttx: fix multiple 'FAR', 'CODE' and style issues 2024-08-25 19:22:15 +08:00
machine arch/x86_64: add basic support for R_X86_64_REX_GOTPCRELX relocation 2024-09-17 03:20:03 +08:00
misc libc/misc/crc32: crc32 add slow mode, optional decrease size 2024-09-12 16:17:21 +02:00
modlib [Bug-Fix] Resource leaks 2024-09-15 10:26:21 +08:00
net netlib/route: add length for add/del route-func to reduce caller stack usage 2024-08-26 01:54:10 +08:00
netdb libc/netdb: Remove unnecessary CONFIG_LIBC_NETDB checks 2024-09-17 03:19:47 +08:00
obstack libs/libc/obstack: revert invalid null byte append to obstack_vprintf 2024-09-17 11:32:48 +08:00
pthread pthread_cleanup: move clenup down to tls 2024-09-14 20:15:12 +08:00
pwd build: Fix libc/pwd CMakeLists.txt 2024-08-07 08:45:19 +08:00
queue libs/libc/queue: inline queue list to improve performance 2024-09-08 18:13:33 +08:00
regex cmake:add missing libc regex CMake support 2024-09-15 10:29:21 +08:00
sched clock: Replace all ts and tick conversion functions 2024-09-12 18:14:39 +08:00
search hcreate: add alloc/free func hook for user to deallocate memory 2024-08-22 20:25:30 +08:00
semaphore semaphore: export priority ceiling interfaces in semaphore 2024-09-10 01:26:31 +08:00
signal
spawn
stdio libs/libc/sscanf: Support pointer format 2024-09-15 10:11:42 +08:00
stdlib libc/stdlib: Refine octal check of lib_checkbase() 2024-09-15 10:11:42 +08:00
stream stream/syslograw: remove support for iob buffer in syslog 2024-09-13 09:14:56 +08:00
string libc/stdlib: If there were no digits at all, strtoul() stores the original value of nptr in *endptr (and returns 0). 2024-09-15 10:11:42 +08:00
symtab
syslog
termios
time enable O_CLOEXEC explicitly to avoid fd leak 2024-09-17 02:07:34 +08:00
tls pthread_cleanup: move clenup down to tls 2024-09-14 20:15:12 +08:00
uio
unistd sys/resource: Add RLIMIT_RTPRIO and RLIMIT_RTTIME definition 2024-09-13 16:08:25 +08:00
userfs
uuid nuttx: fix multiple 'FAR', 'CODE' and style issues 2024-08-25 19:22:15 +08:00
wchar libc:Add macro restrictions to code that uses floating point numbers 2024-08-21 13:33:45 +08:00
wctype
wqueue clock: Replace all ts and tick conversion functions 2024-09-12 18:14:39 +08:00
zoneinfo Revert "build depend:Revert Make.dep intermediate ddc file" 2024-09-15 19:29:47 +08:00
.gitignore
CMakeLists.txt
Kconfig libs/libc/queue: inline queue list to improve performance 2024-09-08 18:13:33 +08:00
libc.csv pthread/realtime: export interfaces about pthread ceiling priority 2024-09-10 01:26:31 +08:00
libc.h
Makefile Revert "build depend:Revert Make.dep intermediate ddc file" 2024-09-15 19:29:47 +08:00