Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test/autofs: fix use-after-free #1732

Merged

Conversation

rst0git
Copy link
Member

@rst0git rst0git commented Jan 27, 2022

Fixes: #1731

@codecov-commenter
Copy link

Codecov Report

Merging #1732 (832d940) into criu-dev (04f8368) will decrease coverage by 0.00%.
The diff coverage is n/a.

❗ Current head 832d940 differs from pull request most recent head cff320d. Consider uploading reports for the commit cff320d to get more accurate results
Impacted file tree graph

@@             Coverage Diff              @@
##           criu-dev    #1732      +/-   ##
============================================
- Coverage     70.68%   70.68%   -0.01%     
============================================
  Files           127      127              
  Lines         30960    30928      -32     
============================================
- Hits          21885    21862      -23     
+ Misses         9075     9066       -9     
Impacted Files Coverage Δ
include/common/lock.h 88.88% <0.00%> (-8.17%) ⬇️
criu/uffd.c 79.36% <0.00%> (ø)
criu/include/image.h 100.00% <0.00%> (ø)
include/common/list.h 100.00% <0.00%> (ø)
criu/include/parasite.h 100.00% <0.00%> (ø)
compel/src/lib/log.c
criu/arch/x86/crtools.c
criu/include/imgset.h
compel/arch/x86/src/lib/cpu.c
criu/include/criu-log.h 100.00% <0.00%> (ø)
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 04f8368...cff320d. Read the comment docs.

autofs.c:66:17: error: pointer 'str' may be used after 'realloc' [-Werror=use-after-free]

autofs.c: In function 'check_automount':
../lib/zdtmtst.h:131:9: error: pointer 'mountpoint' may be used after 'free' [-Werror=use-after-free]
  131 |         test_msg("ERR: %s:%d: " format " (errno = %d (%s))\n", __FILE__, __LINE__, ##arg, errno, strerror(errno))
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
autofs.c:277:17: note: in expansion of macro 'pr_perror'
  277 |                 pr_perror("%s: failed to close fd %d", mountpoint, p->fd);
      |                 ^~~~~~~~~
autofs.c:268:9: note: call to 'free' here
  268 |         free(mountpoint);
      |         ^~~~~~~~~~~~~~~~

Fixes: checkpoint-restore#1731

v2: (@Snorch) always update `str` after successful realloc()

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
@rst0git rst0git force-pushed the autofs-fix-gcc-12-warnings branch from 98c76c2 to 76e541a Compare January 27, 2022 17:17
Copy link
Member

@Snorch Snorch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@adrianreber adrianreber merged commit d72dadd into checkpoint-restore:criu-dev Jan 28, 2022
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.

Another GCC 12 related error (probably)
4 participants