Skip to content

Commit

Permalink
Change signature of sqlite getcwd callback function.
Browse files Browse the repository at this point in the history
Sleeping bug detected by UndefinedBehaviourSanitizer.
While here, simplify the implementation.
  • Loading branch information
Keve authored and bapt committed Nov 23, 2024
1 parent 7458dd3 commit fba3b42
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
5 changes: 0 additions & 5 deletions UndefinedBehaviour.suppress
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
# _external_ sources.
#

# external/sqlite/sqlite3.c:45168:9: runtime error: call to function _dbdir_getcwd through pointer to incorrect function type 'char *(*)(char *, unsigned long)'
# +pkgdb.c:921: note: _dbdir_getcwd defined here
# +SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior external/sqlite/sqlite3.c:45168:9
function:sqlite3.c

# external/picosat/picosat.c:3432:33: runtime error: applying non-zero offset 8 to null pointer
# +SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior external/picosat/picosat.c:3432:33
pointer-overflow:picosat.c
13 changes: 11 additions & 2 deletions libpkg/pkgdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -916,10 +916,19 @@ _dbdir_mkdir(const char *path, mode_t mode)
return (mkdirat(dfd, _dbdir_trim_path(path), mode));
}

static int
static char *
_dbdir_getcwd(char *path, size_t sz)
{
return (snprintf(path, sz, "/"));
if (0 == sz) {
errno = EINVAL;
} else if (sz >= 2) {
path[0] = '/';
path[1] = '\0';
return path;
} else {
errno = ERANGE;
}
return 0;
}

void
Expand Down

0 comments on commit fba3b42

Please sign in to comment.