Skip to content

Commit 94c5cfd

Browse files
committed
Make sure that distributions are only added in Linux not any Unix
1 parent 767f1a9 commit 94c5cfd

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/sentry_os.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,10 @@ sentry__get_os_context(void)
198198
# include <fcntl.h>
199199
# include <sys/utsname.h>
200200

201-
# define OS_RELEASE_MAX_LINE_SIZE 128
202-
# define OS_RELEASE_MAX_KEY_SIZE 64
203-
# define OS_RELEASE_MAX_VALUE_SIZE 128
201+
# if defined(SENTRY_PLATFORM_LINUX)
202+
# define OS_RELEASE_MAX_LINE_SIZE 128
203+
# define OS_RELEASE_MAX_KEY_SIZE 64
204+
# define OS_RELEASE_MAX_VALUE_SIZE 128
204205

205206
static int
206207
parse_os_release_line(const char *line, char *key, char *value)
@@ -226,9 +227,9 @@ parse_os_release_line(const char *line, char *key, char *value)
226227
return 0;
227228
}
228229

229-
# ifndef SENTRY_UNITTEST
230+
# ifndef SENTRY_UNITTEST
230231
static
231-
# endif
232+
# endif
232233
sentry_value_t
233234
get_linux_os_release(const char *os_rel_path)
234235
{
@@ -291,6 +292,7 @@ static
291292

292293
return os_dist;
293294
}
295+
# endif // defined(SENTRY_PLATFORM_LINUX)
294296

295297
sentry_value_t
296298
sentry__get_os_context(void)
@@ -332,6 +334,7 @@ sentry__get_os_context(void)
332334
sentry_value_set_by_key(
333335
os, "version", sentry_value_new_string(uts.release));
334336

337+
# if defined(SENTRY_PLATFORM_LINUX)
335338
/**
336339
* The file /etc/os-release takes precedence over /usr/lib/os-release.
337340
* Applications should check for the former, and exclusively use its data if
@@ -350,6 +353,7 @@ sentry__get_os_context(void)
350353
} else {
351354
sentry_value_set_by_key(os, "distribution", os_dist);
352355
}
356+
# endif // defined(SENTRY_PLATFORM_LINUX)
353357

354358
return os;
355359

0 commit comments

Comments
 (0)