Skip to content

rofs: handle empty string in lookup#137

Merged
badochov merged 1 commit intomasterfrom
badochov/gcc-14.2
Oct 9, 2024
Merged

rofs: handle empty string in lookup#137
badochov merged 1 commit intomasterfrom
badochov/gcc-14.2

Conversation

@badochov
Copy link
Contributor

@badochov badochov commented Sep 27, 2024

JIRA: RTOS-927

Description

If "\0" was passed unitialzed res would be returned

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (refactoring, style fixes, git/CI config, submodule management, no code logic changes)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: (list targets here).

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

  • This PR needs additional PRs to work (list the PRs, preferably in merge-order).
  • I will merge this PR by myself when appropriate.

@github-actions
Copy link

github-actions bot commented Sep 27, 2024

Unit Test Results

7 725 tests  +2   7 010 ✅ +2   38m 51s ⏱️ +11s
  445 suites +2     715 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 538f710. ± Comparison against base commit 1533188.

♻️ This comment has been updated with latest results.

Copy link
Member

@Darchiv Darchiv left a comment

Choose a reason for hiding this comment

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

Minor nitpicks.

Please tick appropriate ticks (at least the type(s) of changes).

rofs/rofs.c Outdated

fil->port = ctx->oid.port;
if (name == NULL) {
if ((name == NULL) || (name[0] == '\0')) {
Copy link
Member

Choose a reason for hiding this comment

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

In case of name[0] == '\0', dirfind() returns -ENOENT, so this should also be the case here. Maybe initialize res with -ENOENT or add a separate if?

rofs/rofs.c Outdated

while (name[len] != '\0') {
while (name[len] == '/' && name[len] != '\0') {
while ((name[len] == '/') && (name[len] != '\0')) {
Copy link
Member

Choose a reason for hiding this comment

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

Just noticed this - if name[0] == '/', then it certainly isn't '\0'

@badochov badochov changed the title rofs: check for empty string in lookup rofs: handle empty string in lookup Oct 8, 2024
@badochov badochov requested a review from Darchiv October 8, 2024 16:43
@badochov badochov merged commit 2c98d2b into master Oct 9, 2024
@badochov badochov deleted the badochov/gcc-14.2 branch October 9, 2024 09:08
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