Skip to content

fix(common: xutil: xutil_get_text_property_from_reply): guard memcpy from receiving non-positive length - #4136

Open
actionless wants to merge 5 commits into
awesomeWM:masterfrom
actionless:fix-common-xutil-negative-len
Open

actionless wants to merge 5 commits into
awesomeWM:masterfrom
actionless:fix-common-xutil-negative-len

Conversation

@actionless

@actionless actionless commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

currently the build throws a warning:

[ 85%] Linking C executable awesome
In function ‘memcpy’,
    inlined from ‘xutil_get_text_property_from_reply’ at /home/lie/.cache/pikaur/build/awesome-luajit-git/src/build/common/xutil.h:50:9,
    inlined from ‘client_manage’ at /home/lie/.cache/pikaur/build/awesome-luajit-git/src/build/objects/client.c:2410:24:
/usr/include/bits/string_fortified.h:29:10: warning: ‘__builtin_memcpy’ specified bound between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 922337203
6854775807 [-Wstringop-overflow=]
   29 |   return __builtin___memcpy_chk (__dest, __src, __len,
      |          ^
[100%] Built target awesome

because since xcb_get_property_value_length() returns a signed int, it makes the range of return value which later passed to memcpy() as length potentially negative

and above would cause to overflow the length into aforementioned length in the warning message

@codecov

codecov Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.43%. Comparing base (c463e19) to head (d060382).

Files with missing lines Patch % Lines
common/xutil.h 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4136      +/-   ##
==========================================
- Coverage   90.43%   90.43%   -0.01%     
==========================================
  Files         941      941              
  Lines       60363    60364       +1     
  Branches     1139     1140       +1     
==========================================
  Hits        54591    54591              
  Misses       5266     5266              
- Partials      506      507       +1     
Files with missing lines Coverage Δ
common/xutil.h 87.50% <85.71%> (-5.84%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…memcpy from receiving negative length

fix(common: xutil: xutil_get_text_property_from_reply): simplify the code
@actionless
actionless force-pushed the fix-common-xutil-negative-len branch from 959f58b to 40dffad Compare November 1, 2026 13:52
@actionless actionless changed the title fix(common: xutil: xutil_get_text_property_from_reply): guard memcpy from receiving negative length fix(common: xutil: xutil_get_text_property_from_reply): guard memcpy from receiving non-positive length Nov 1, 2026
… guard memcpy from receiving negative length

fix(common: xutil: xutil_get_text_property_from_reply): simplify the code
…h to size_t to avoid potential INT_MAX overflow during `length + 1`
@actionless
actionless requested a review from Aire-One November 3, 2026 21:30
@Aire-One

Aire-One commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

I think it's a duplicate of #4087.

I don't get this warning when building Awesome, and the latest CI run on master also don't report it (https://github.com/awesomeWM/awesome/actions/runs/40995784216/job/123868463047).

I guess this is due to using another C compiler. @cnjhb mentioned they use clang.

I haven't had the time to complete my work yet, but I think we should have a way to build Awesome with clang in our CI, and/or run clang-tidy to lint the C code. This would automatically detect and force us to resolve all these issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants