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

[Plat-11044] remove stat #1614

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Bugsnag/Helpers/BSGRunContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -557,13 +557,14 @@ static int OpenFile(NSString *_Nonnull path) {
/// Loads the contents of the state file into memory and sets the
/// `bsg_lastRunContext` pointer if the contents are valid.
static void LoadLastRunContext(int fd) {
struct stat sb;
static struct BSGRunContext context;
uint8_t buff[SIZEOF_STRUCT+1]; // +1 to detect if the size grew

// Only expose previous state if size matches...
if (fstat(fd, &sb) == 0 && sb.st_size == SIZEOF_STRUCT) {
static struct BSGRunContext context;
if (read(fd, &context, SIZEOF_STRUCT) == SIZEOF_STRUCT &&
// ...and so does the structVersion
context.structVersion == BSGRUNCONTEXT_VERSION) {
if (read(fd, buff, sizeof(buff)) == SIZEOF_STRUCT) {
memcpy(&context, buff, SIZEOF_STRUCT);
// ...and so does the structVersion
if (context.structVersion == BSGRUNCONTEXT_VERSION) {
bsg_lastRunContext = &context;
}
}
Expand Down
7 changes: 4 additions & 3 deletions Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_Jailbreak.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
#ifndef bsg_jailbreak_h
#define bsg_jailbreak_h

#include <dirent.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <TargetConditionals.h>
Expand Down Expand Up @@ -195,9 +195,10 @@ static inline bool bsg_local_is_insert_libraries_env_var(const char* str) {
} \
\
const char* etc_apt_path = "/etc/apt"; \
struct stat st; \
if(stat(etc_apt_path, &st) == 0) { \
DIR *dirp = opendir(etc_apt_path); \
if(dirp) { \
etc_apt_exists = true; \
closedir(dirp); \
} \
\
for(int i = 0; environ[i] != NULL; i++) { \
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ GEM
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
nokogiri (1.15.5-arm64-darwin)
racc (~> 1.4)
nokogiri (1.15.5-x86_64-darwin)
racc (~> 1.4)
optimist (3.0.1)
Expand Down Expand Up @@ -208,6 +210,7 @@ GEM
rexml (~> 3.2.4)

PLATFORMS
arm64-darwin-22
x86_64-darwin-19

DEPENDENCIES
Expand Down
Loading