base: Fix off-by-one in abstract unix socket names

The code in UnixSocket was appending an extra \0 to the
socket name. So PERFETTO_CONSUMER_SOCK_NAME=@foo ended up
with a socket named "foo\0". This worked fine because both
client and server were affected consistently by the same bug.
However, this breaks interoperatbility with other tools,
most notably UI integration with adb, which doesn't support
ADB forwarding of non-ASCII abstract socket names.
Filesystem linked sockets are not affected by the bug, as
man 7 unix explicily says they must be null-terminated.

Note: this change is technically breaking the ABI of the
socket. We just think that the risk of anybody overriding the
socket with PERFETTO_CONSUMER_SOCK_NAME=@xxx is extremely low
given that abstract sockets are mostly used in testing purposes.
An internal code search and PSA on the mailing list returned
no potential breakages.

Bug: 239725760
Test: perfetto_unittests --gtest_filter=UnixSocketTest.Sockaddr*
Test: manual: start traced; socat 'UNIX-CONNECT:/tmp/perfetto-producer' /dev/stdout
Test: manual: start PERFETTO_CONSUMER_SOCK_NAME=@foo traced; socat 'ABSTRACT-CONNECT:foo' /dev/stdout

Change-Id: I478e5ff09aa78dc417c372c8906f241cb2cf0046
3 files changed
tree: 996a3aaafba69fe65d2d16be2d620b6571eb4841
  1. .github/
  2. bazel/
  3. build_overrides/
  4. buildtools/
  5. debian/
  6. docs/
  7. examples/
  8. gn/
  9. include/
  10. infra/
  11. protos/
  12. python/
  13. src/
  14. test/
  15. tools/
  16. ui/
  17. .clang-format
  18. .clang-tidy
  19. .gitattributes
  20. .gitignore
  21. .gn
  22. .style.yapf
  23. Android.bp
  24. Android.bp.extras
  25. BUILD
  26. BUILD.extras
  27. BUILD.gn
  28. CHANGELOG
  29. codereview.settings
  30. DIR_METADATA
  31. heapprofd.rc
  32. LICENSE
  33. meson.build
  34. METADATA
  35. MODULE_LICENSE_APACHE2
  36. OWNERS
  37. perfetto.rc
  38. PerfettoIntegrationTests.xml
  39. PRESUBMIT.py
  40. README.chromium
  41. README.md
  42. TEST_MAPPING
  43. traced_perf.rc
  44. WORKSPACE
README.md

Perfetto - System profiling, app tracing and trace analysis

Perfetto is a production-grade open-source stack for performance instrumentation and trace analysis. It offers services and libraries and for recording system-level and app-level traces, native + java heap profiling, a library for analyzing traces using SQL and a web-based UI to visualize and explore multi-GB traces.

See https://perfetto.dev/docs or the /docs/ directory for documentation.