MCPcopy Create free account
hub / github.com/MariaDB/server / init

Method init

sql/sql_acl.cc:623–667  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

621}
622
623bool ROLE_GRANT_PAIR::init(MEM_ROOT *mem,
624 const LEX_CSTRING &username,
625 const LEX_CSTRING &hostname,
626 const LEX_CSTRING &rolename,
627 bool with_admin_option)
628{
629 /*
630 Create a buffer that holds all 3 NULL terminated strings in succession
631 To save memory space, the same buffer is used as the hashkey
632 Add the '\0' as well.
633 */
634 size_t bufflen= username.length + hostname.length + rolename.length + 3;
635 char *buff= (char *)alloc_root(mem, bufflen);
636 if (!buff)
637 return true;
638
639 /*
640 Offsets in the buffer for all 3 strings
641 */
642 char *username_pos= buff;
643 char *hostname_pos= buff + username.length + 1;
644 char *rolename_pos= buff + username.length + hostname.length + 2;
645
646 if (username.str) //prevent undefined behaviour
647 memcpy(username_pos, username.str, username.length);
648 username_pos[username.length]= '\0'; //#1 string terminator
649 u_uname= Lex_cstring(username_pos, username.length);
650
651 if (hostname.str) //prevent undefined behaviour
652 memcpy(hostname_pos, hostname.str, hostname.length);
653 hostname_pos[hostname.length]= '\0'; //#2 string terminator
654 u_hname= Lex_cstring(hostname_pos, hostname.length);
655
656 if (rolename.str) //prevent undefined behaviour
657 memcpy(rolename_pos, rolename.str, rolename.length);
658 rolename_pos[rolename.length]= '\0'; //#3 string terminator
659 r_uname= Lex_cstring(rolename_pos, rolename.length);
660
661 hashkey.str = buff;
662 hashkey.length = bufflen;
663
664 with_admin= with_admin_option;
665
666 return false;
667}
668
669#define IP_ADDR_STRLEN (3 + 1 + 3 + 1 + 3 + 1 + 3)
670

Callers 7

acl_loadFunction · 0.45
acl_reloadFunction · 0.45
acl_getrootFunction · 0.45
update_role_mappingFunction · 0.45
handle_grant_structFunction · 0.45
acl_setauthorizationFunction · 0.45

Calls 11

alloc_rootFunction · 0.85
Lex_cstringClass · 0.85
safe_strFunction · 0.85
proxied_hostMethod · 0.80
proxied_userMethod · 0.80
with_grantMethod · 0.80
get_fieldFunction · 0.70
initFunction · 0.50
hostMethod · 0.45
userMethod · 0.45
val_intMethod · 0.45

Tested by

no test coverage detected