FreeBSD Bugzilla – Attachment 219556 Details for
Bug 251025
efivar: Cannot write to EFI variables which have a '-' in their name
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
possible fix using regex to match guid part
efivar.diff (text/plain), 982 bytes, created by
Yuri Pankov
on 2020-11-11 14:31:19 UTC
(
hide
)
Description:
possible fix using regex to match guid part
Filename:
MIME Type:
Creator:
Yuri Pankov
Created:
2020-11-11 14:31:19 UTC
Size:
982 bytes
patch
obsolete
>diff --git a/usr.sbin/efivar/efivar.c b/usr.sbin/efivar/efivar.c >index c1d36b9bb0b..42dfa985955 100644 >--- a/usr.sbin/efivar/efivar.c >+++ b/usr.sbin/efivar/efivar.c >@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); > #include <errno.h> > #include <fcntl.h> > #include <getopt.h> >+#include <regex.h> > #include <stddef.h> > #include <stdio.h> > #include <stdlib.h> >@@ -88,12 +89,19 @@ static void > breakdown_name(char *name, efi_guid_t *guid, char **vname) > { > char *cp; >+ regex_t re; >+ regmatch_t rm[1]; > >- cp = strrchr(name, '-'); >- if (cp == NULL) >+ if (regcomp(&re, "^[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-" >+ "[[:xdigit:]]{4}-[[:xdigit:]]{12}-", REG_EXTENDED | REG_ICASE) != 0) >+ errx(1, "failed to compile regex"); >+ if (regexec(&re, name, 1, rm, 0) != 0) > errx(1, "Invalid name: %s", name); >- *vname = cp + 1; >+ regfree(&re); >+ >+ cp = name + rm[0].rm_eo - 1; > *cp = '\0'; >+ *vname = cp + 1; > if (efi_name_to_guid(name, guid) < 0) > errx(1, "Invalid guid %s", name); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 251025
: 219556