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

fix iptux stackoverflow when receiving dir #656

Merged
merged 1 commit into from
Feb 8, 2025
Merged

Conversation

lidaobing
Copy link
Member

@lidaobing lidaobing commented Feb 8, 2025

/close #472

g_mkdir is macro define to mkidr, so when we call g_mkdir in AnalogFS::mkdir, it will call itself. cause stackoverflow.

Summary by Sourcery

Bug Fixes:

  • Fixed a stack overflow error that occurred when creating directories during file transfer. The issue was caused by inadvertently calling mkdir recursively.

Copy link

sourcery-ai bot commented Feb 8, 2025

Reviewer's Guide by Sourcery

This pull request addresses a stack overflow issue caused by the recursive invocation of the 'g_mkdir' macro within the 'AnalogFS::mkdir' method. The solution involves renaming and updating the directory creation method from 'mkdir' to 'makeDir' to prevent self-referential calls in both the implementation and its usage.

Updated Class Diagram for AnalogFS (Renaming mkdir to makeDir)

classDiagram
    class AnalogFS {
      +int open(const char* fn, int flags)
      +int open(const char* fn, int flags, mode_t mode)
      +int stat(const char* fn, struct ::stat* st)
      +int makeDir(const char* dir, mode_t mode)
      +int64_t ftwsize(const char* dir)
      +DIR* opendir(const char* dir)
    }
    note for AnalogFS "Renamed mkdir to makeDir to avoid recursive macro call causing stack overflow"
Loading

File-Level Changes

Change Details Files
Update of directory creation function usage in the file receiving process.
  • Replaced the call to 'afs.mkdir' with 'afs.makeDir' in RecvFileData.cpp for creating the file archive directory.
  • Replaced the call to 'afs.mkdir' with 'afs.makeDir' in RecvFileData.cpp when handling directory entries.
src/iptux-core/internal/RecvFileData.cpp
Rename and update the directory creation function in the AnalogFS implementation.
  • Renamed the 'mkdir' method to 'makeDir' in the AnalogFS.cpp file to avoid recursive macro expansion.
  • Updated the function declaration accordingly in the AnalogFS.h header file.
src/iptux-core/internal/AnalogFS.cpp
src/iptux-core/internal/AnalogFS.h

Assessment against linked issues

Issue Objective Addressed Explanation
#472 Fix app crash when receiving a shared folder

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @lidaobing - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Ensure all calls to the directory creation function have been updated to use makeDir to avoid inadvertent calls to the macro-expanded g_mkdir.
  • Double-check that the interface change from mkdir to makeDir does not break any expected usage in the filesystem abstraction layer.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

github-actions bot commented Feb 8, 2025

Test Results

66 tests  ±0   66 ✅ ±0   1s ⏱️ -3s
32 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 6efeb55. ± Comparison against base commit a926505.

Copy link

codecov bot commented Feb 8, 2025

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 52.48%. Comparing base (a926505) to head (6efeb55).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/iptux-core/internal/RecvFileData.cpp 0.00% 2 Missing ⚠️
src/iptux-core/internal/AnalogFS.cpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #656      +/-   ##
==========================================
+ Coverage   52.47%   52.48%   +0.01%     
==========================================
  Files          64       64              
  Lines        8558     8558              
==========================================
+ Hits         4491     4492       +1     
+ Misses       4067     4066       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lidaobing lidaobing merged commit ec45ec3 into master Feb 8, 2025
14 of 18 checks passed
@lidaobing lidaobing deleted the bf_472_crash branch February 8, 2025 22:05
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.

Receiving shared folder causes the app to crash
1 participant