Browse Source

Rename strpartcmp_static to strstartswith_static

Michał Kowalczyk 4 years ago
parent
commit
5383e825a3

+ 4 - 4
LibOS/shim/src/fs/chroot/fs.c

@@ -63,11 +63,11 @@ static int chroot_mount (const char * uri, void ** mount_data)
 {
     enum shim_file_type type;
 
-    if (strpartcmp_static(uri, "file:")) {
+    if (strstartswith_static(uri, "file:")) {
         type = FILE_UNKNOWN;
         uri += 5;
-    } else if (strpartcmp_static(uri, "dev:")) {
-        type = strpartcmp_static(uri + static_strlen("dev:"), "tty") ? FILE_TTY : FILE_DEV;
+    } else if (strstartswith_static(uri, "dev:")) {
+        type = strstartswith_static(uri + static_strlen("dev:"), "tty") ? FILE_TTY : FILE_DEV;
         uri += 4;
     } else
         return -EINVAL;
@@ -1017,7 +1017,7 @@ static int chroot_readdir(struct shim_dentry* dent, struct shim_dirent** dirent)
     chroot_update_ino(dent);
 
     const char* uri = qstrgetstr(&data->host_uri);
-    assert(strpartcmp_static(uri, "dir:"));
+    assert(strstartswith_static(uri, "dir:"));
 
     pal_hdl = DkStreamOpen(uri, PAL_ACCESS_RDONLY, 0, 0, 0);
     if (!pal_hdl)

+ 1 - 1
LibOS/shim/src/fs/proc/thread.c

@@ -25,7 +25,7 @@ static int parse_thread_name(const char* name, IDTYPE* pidptr, const char** next
     if (*p == '/')
         p++;
 
-    if (strpartcmp_static(p, "self")) {
+    if (strstartswith_static(p, "self")) {
         p += static_strlen("self");
         if (*p && *p != '/')
             return -ENOENT;

+ 3 - 3
LibOS/shim/src/shim_init.c

@@ -409,7 +409,7 @@ int init_stack (const char ** argv, const char ** envp,
 int read_environs (const char ** envp)
 {
     for (const char ** e = envp ; *e ; e++) {
-        if (strpartcmp_static(*e, "LD_LIBRARY_PATH=")) {
+        if (strstartswith_static(*e, "LD_LIBRARY_PATH=")) {
             /* populate library_paths with entries from LD_LIBRARY_PATH envvar */
             const char * s = *e + static_strlen("LD_LIBRARY_PATH=");
             size_t npaths = 2; // One for the first entry, one for the last
@@ -549,7 +549,7 @@ static void set_profile_enabled (const char ** envp)
 {
     const char ** p;
     for (p = envp ; (*p) ; p++)
-        if (strpartcmp_static(*p, "PROFILE_ENABLED="))
+        if (strstartswith_static(*p, "PROFILE_ENABLED="))
             break;
     if (!(*p))
         return;
@@ -969,7 +969,7 @@ static int open_pal_handle (const char * uri, void * obj)
 {
     PAL_HANDLE hdl;
 
-    if (strpartcmp_static(uri, "dev:"))
+    if (strstartswith_static(uri, "dev:"))
         hdl = DkStreamOpen(uri, 0,
                            PAL_SHARE_OWNER_X|PAL_SHARE_OWNER_W|
                            PAL_SHARE_OWNER_R,

+ 1 - 1
Pal/lib/api.h

@@ -126,7 +126,7 @@ void *calloc(size_t nmemb, size_t size);
     (memcmp(var, force_literal_cstr(str), static_strlen(force_literal_cstr(str)) + 1))
 
 /* check if the var starts with the static string */
-#define strpartcmp_static(var, str) \
+#define strstartswith_static(var, str) \
     (!memcmp(var, force_literal_cstr(str), static_strlen(force_literal_cstr(str))))
 
 /* copy static string and return the address of the null end (null if the dest

+ 1 - 1
Pal/src/db_rtld.c

@@ -1218,7 +1218,7 @@ void DkDebugAttachBinary (PAL_STR uri, PAL_PTR start_addr)
     __UNUSED(uri);
     __UNUSED(start_addr);
 #else
-    if (!strpartcmp_static(uri, "file:"))
+    if (!strstartswith_static(uri, "file:"))
         return;
 
     const char * realname = uri + static_strlen("file:");

+ 10 - 10
Pal/src/db_streams.c

@@ -82,34 +82,34 @@ static int parse_stream_uri(const char** uri, char** prefix, struct handle_ops**
 
     switch (p - u) {
         case 3:
-            if (strpartcmp_static(u, "dir"))
+            if (strstartswith_static(u, "dir"))
                 hops = &dir_ops;
-            else if (strpartcmp_static(u, "tcp"))
+            else if (strstartswith_static(u, "tcp"))
                 hops = &tcp_ops;
-            else if (strpartcmp_static(u, "udp"))
+            else if (strstartswith_static(u, "udp"))
                 hops = &udp_ops;
-            else if (strpartcmp_static(u, "dev"))
+            else if (strstartswith_static(u, "dev"))
                 hops = &dev_ops;
             break;
 
         case 4:
-            if (strpartcmp_static(u, "file"))
+            if (strstartswith_static(u, "file"))
                 hops = &file_ops;
-            else if (strpartcmp_static(u, "pipe"))
+            else if (strstartswith_static(u, "pipe"))
                 hops = &pipe_ops;
-            else if (strpartcmp_static(u, "gipc"))
+            else if (strstartswith_static(u, "gipc"))
                 hops = &gipc_ops;
             break;
 
         case 7:
-            if (strpartcmp_static(u, "tcp.srv"))
+            if (strstartswith_static(u, "tcp.srv"))
                 hops = &tcp_ops;
-            else if (strpartcmp_static(u, "udp.srv"))
+            else if (strstartswith_static(u, "udp.srv"))
                 hops = &udp_ops;
             break;
 
         case 8:
-            if (strpartcmp_static(u, "pipe.srv"))
+            if (strstartswith_static(u, "pipe.srv"))
                 hops = &pipe_ops;
             break;
 

+ 1 - 1
Pal/src/host/FreeBSD/db_devices.c

@@ -63,7 +63,7 @@ static int parse_device_uri(const char ** uri, char ** type, struct handle_ops *
 
     for (p = u ; (*p) && (*p) != ',' && (*p) != '/' ; p++);
 
-    if (strpartcmp_static(u, "tty"))
+    if (strstartswith_static(u, "tty"))
         dops = &term_ops;
 
     if (!dops)

+ 1 - 1
Pal/src/host/FreeBSD/db_sockets.c

@@ -908,7 +908,7 @@ static int udp_sendbyaddr (PAL_HANDLE handle, int offset, int len,
     if (handle->sock.fd == PAL_IDX_POISON)
         return -PAL_ERROR_BADHANDLE;
 
-    if (!strpartcmp_static(addr, "udp:"))
+    if (!strstartswith_static(addr, "udp:"))
         return -PAL_ERROR_INVAL;
 
     addr += static_strlen("udp:");

+ 1 - 1
Pal/src/host/Linux-SGX/db_devices.c

@@ -66,7 +66,7 @@ static int parse_device_uri(const char** uri, char** type, struct handle_ops** o
     for (p = u; (*p) && (*p) != ',' && (*p) != '/'; p++)
         ;
 
-    if (strpartcmp_static(u, "tty"))
+    if (strstartswith_static(u, "tty"))
         dops = &term_ops;
 
     if (!dops)

+ 1 - 1
Pal/src/host/Linux-SGX/db_main.c

@@ -96,7 +96,7 @@ int init_child_process(PAL_HANDLE* parent_handle);
  */
 static PAL_HANDLE setup_dummy_file_handle (const char * name)
 {
-    if (!strpartcmp_static(name, "file:"))
+    if (!strstartswith_static(name, "file:"))
         return NULL;
 
     name += static_strlen("file:");

+ 1 - 1
Pal/src/host/Linux-SGX/db_process.c

@@ -248,7 +248,7 @@ static int check_child_mrenclave(PAL_HANDLE child, sgx_arch_hash_t* mrenclave,
 int _DkProcessCreate (PAL_HANDLE * handle, const char * uri, const char ** args)
 {
     /* only access creating process with regular file */
-    if (!strpartcmp_static(uri, "file:"))
+    if (!strstartswith_static(uri, "file:"))
         return -PAL_ERROR_INVAL;
 
     unsigned int child_pid;

+ 1 - 1
Pal/src/host/Linux-SGX/db_rtld.c

@@ -121,7 +121,7 @@ void _DkDebugAddMap (struct link_map * map)
             continue;
         if (s->sh_type == SHT_NULL)
             continue;
-        if (strpartcmp_static(shstrtab + s->sh_name, ".debug_"))
+        if (strstartswith_static(shstrtab + s->sh_name, ".debug_"))
             continue;
 
         snprintf(ptr, BUFFER_LENGTH - (ptr - buffer),

+ 1 - 1
Pal/src/host/Linux-SGX/db_sockets.c

@@ -708,7 +708,7 @@ static int64_t udp_sendbyaddr(PAL_HANDLE handle, uint64_t offset, uint64_t len,
     if (handle->sock.fd == PAL_IDX_POISON)
         return -PAL_ERROR_BADHANDLE;
 
-    if (!strpartcmp_static(addr, "udp:"))
+    if (!strstartswith_static(addr, "udp:"))
         return -PAL_ERROR_INVAL;
 
     if (len >= (1ULL << (sizeof(unsigned int) * 8)))

+ 2 - 2
Pal/src/host/Linux-SGX/enclave_framework.c

@@ -280,7 +280,7 @@ int load_trusted_file (PAL_HANDLE file, sgx_stub_t ** stubptr,
     }
 
     /* Normalize the uri */
-    if (!strpartcmp_static(uri, "file:")) {
+    if (!strstartswith_static(uri, "file:")) {
         SGX_DBG(DBG_E, "Invalid URI [%s]: Trusted files must start with 'file:'\n", uri);;
         return -PAL_ERROR_INVAL;
     }
@@ -707,7 +707,7 @@ static int init_trusted_file (const char * key, const char * uri)
         return 0;
 
     /* Normalize the uri */
-    if (!strpartcmp_static(uri, "file:")) {
+    if (!strstartswith_static(uri, "file:")) {
         SGX_DBG(DBG_E, "Invalid URI [%s]: Trusted files must start with 'file:'\n", uri);
         return -PAL_ERROR_INVAL;
     }

+ 4 - 4
Pal/src/host/Linux-SGX/enclave_platform.c

@@ -349,13 +349,13 @@ static int parse_x509_pem(char* cert, char** cert_end, uint8_t** body, size_t* b
         return 0;
     }
 
-    if (!strpartcmp_static(start, "-----BEGIN CERTIFICATE-----"))
+    if (!strstartswith_static(start, "-----BEGIN CERTIFICATE-----"))
         return -PAL_ERROR_INVAL;
 
     start += static_strlen("-----BEGIN CERTIFICATE-----");
     char* end = strchr(start, '-');
 
-    if (!strpartcmp_static(end, "-----END CERTIFICATE-----"))
+    if (!strstartswith_static(end, "-----END CERTIFICATE-----"))
         return -PAL_ERROR_INVAL;
 
     size_t cert_der_len;
@@ -595,8 +595,8 @@ int sgx_verify_platform(sgx_spid_t* spid, const char* subkey, sgx_quote_nonce_t*
     SGX_DBG(DBG_S, "  timestamp: %s\n", ias_timestamp);
 
     // Only accept status to be "OK" or "GROUP_OUT_OF_DATE" (if accept_out_of_date is true)
-    if (!strcmp_static(ias_status, "OK") &&
-        (!accept_group_out_of_date || !strcmp_static(ias_status, "GROUP_OUT_OF_DATE"))) {
+    if (strcmp_static(ias_status, "OK") &&
+        (!accept_group_out_of_date || strcmp_static(ias_status, "GROUP_OUT_OF_DATE"))) {
         SGX_DBG(DBG_E, "IAS returned invalid status: %s\n", ias_status);
         goto failed;
     }

+ 2 - 2
Pal/src/host/Linux-SGX/sgx_main.c

@@ -79,7 +79,7 @@ static unsigned long parse_int (const char * str)
 
 static char * resolve_uri (const char * uri, const char ** errstring)
 {
-    if (!strpartcmp_static(uri, "file:")) {
+    if (!strstartswith_static(uri, "file:")) {
         *errstring = "Invalid URI";
         return NULL;
     }
@@ -796,7 +796,7 @@ static int load_enclave (struct pal_enclave * enclave,
         if (!strcmp_static(&env[env_i], "IN_GDB=1")) {
             SGX_DBG(DBG_I, "[ Running under GDB ]\n");
             pal_sec->in_gdb = true;
-        } else if (strpartcmp_static(&env[env_i], "LD_PRELOAD=")) {
+        } else if (strstartswith_static(&env[env_i], "LD_PRELOAD=")) {
             uint64_t env_i_size = strnlen(&env[env_i], env_size - env_i) + 1;
             memmove(&env[env_i], &env[env_i + env_i_size], env_size - env_i - env_i_size);
             env_size -= env_i_size;

+ 2 - 2
Pal/src/host/Linux-SGX/sgx_platform.c

@@ -278,7 +278,7 @@ int contact_intel_attest_service(const char* subkey, const sgx_quote_nonce_t* no
         if (end > start + 1 && *(end - 1) == '\r')
             end--;
 
-        if (strpartcmp_static(start, "X-IASReport-Signature: ")) {
+        if (strstartswith_static(start, "X-IASReport-Signature: ")) {
             start += static_strlen("X-IASReport-Signature: ");
 
             // Decode IAS report signature
@@ -301,7 +301,7 @@ int contact_intel_attest_service(const char* subkey, const sgx_quote_nonce_t* no
                 SGX_DBG(DBG_E, "Malformed IAS report signature\n");
                 goto failed;
             }
-        } else if (strpartcmp_static(start, "X-IASReport-Signing-Certificate: ")) {
+        } else if (strstartswith_static(start, "X-IASReport-Signing-Certificate: ")) {
             start += static_strlen("X-IASReport-Signing-Certificate: ");
 
             // Decode IAS signature chain

+ 1 - 1
Pal/src/host/Linux-SGX/sgx_process.c

@@ -84,7 +84,7 @@ int sgx_create_process(const char* uri, int nargs, const char** args, int * retf
     int ret, rete, child;
     int fds[6] = { -1, -1, -1, -1, -1, -1 };
 
-    if (!uri || !strpartcmp_static(uri, "file:"))
+    if (!uri || !strstartswith_static(uri, "file:"))
         return -EINVAL;
 
     if (IS_ERR((ret = INLINE_SYSCALL(pipe, 1, &fds[0]))) ||

+ 1 - 1
Pal/src/host/Linux/db_devices.c

@@ -64,7 +64,7 @@ static int parse_device_uri(const char** uri, char** type, struct handle_ops** o
     for (p = u; (*p) && (*p) != ',' && (*p) != '/'; p++)
         ;
 
-    if (strpartcmp_static(u, "tty"))
+    if (strstartswith_static(u, "tty"))
         dops = &term_ops;
 
     if (!dops)

+ 1 - 1
Pal/src/host/Linux/db_sockets.c

@@ -879,7 +879,7 @@ static int64_t udp_sendbyaddr(PAL_HANDLE handle, uint64_t offset, size_t len, co
     if (handle->sock.fd == PAL_IDX_POISON)
         return -PAL_ERROR_BADHANDLE;
 
-    if (!strpartcmp_static(addr, "udp:"))
+    if (!strstartswith_static(addr, "udp:"))
         return -PAL_ERROR_INVAL;
 
     addr += static_strlen("udp:");

+ 1 - 1
Pal/src/host/Skeleton/db_devices.c

@@ -56,7 +56,7 @@ static int parse_device_uri(const char ** uri, char ** type, struct handle_ops *
 
     for (p = u ; (*p) && (*p) != ',' && (*p) != '/' ; p++);
 
-    if (strpartcmp_static(u, "tty"))
+    if (strstartswith_static(u, "tty"))
         dops = &term_ops;
 
     if (!dops)