KernelUtils: make failure to call & parse uname abort
In practice this is already the case... If uname() execution fails, or we fail to parse the result, we won't pass the 4.9+ required check in NetBpfLoad, which is required on S+, and mainline no longer supports anything <S anyway. We don't require subversion as technically "4.9" (ie. 4.9.0) is enough for almost all usecases, although in practice I would expect there will always be an LTS subversion present. Test: TreeHugger Flag: EXEMPT mainline Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I66a5eba5c7bcf9bd51997db93c0fefc8104945eb
This commit is contained in:
parent
168c6c90ab
commit
e9517aedd3
1 changed files with 3 additions and 2 deletions
|
|
@ -17,6 +17,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/personality.h>
|
||||
#include <sys/utsname.h>
|
||||
|
|
@ -28,12 +29,12 @@ namespace bpf {
|
|||
|
||||
static inline unsigned uncachedKernelVersion() {
|
||||
struct utsname buf;
|
||||
if (uname(&buf)) return 0;
|
||||
if (uname(&buf)) abort();
|
||||
|
||||
unsigned kver_major = 0;
|
||||
unsigned kver_minor = 0;
|
||||
unsigned kver_sub = 0;
|
||||
(void)sscanf(buf.release, "%u.%u.%u", &kver_major, &kver_minor, &kver_sub);
|
||||
if (sscanf(buf.release, "%u.%u.%u", &kver_major, &kver_minor, &kver_sub) < 2) abort();
|
||||
return KVER(kver_major, kver_minor, kver_sub);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue