[libbluray-devel] [Git][videolan/libbluray][master] 3 commits: str_print_hex: Make sure hex strings are nul-terminated
Petri Hintukainen
gitlab at videolan.org
Sun Apr 4 15:30:11 UTC 2021
Petri Hintukainen pushed to branch master at VideoLAN / libbluray
Commits:
adb7b484 by hpi1 at 2021-04-04T18:19:33+03:00
str_print_hex: Make sure hex strings are nul-terminated
- - - - -
be6d6f58 by hpi1 at 2021-04-04T18:19:49+03:00
bdj: Improve logging.
- - - - -
02141b8b by hpi1 at 2021-04-04T18:28:23+03:00
Simplify
- - - - -
2 changed files:
- src/libbluray/bdj/bdj.c
- src/util/strutl.c
Changes:
=====================================
src/libbluray/bdj/bdj.c
=====================================
@@ -441,11 +441,13 @@ static void *_load_jvm(const char **p_java_home, const char *app_java_home)
/* JAVA_HOME set, use it */
java_home = getenv("JAVA_HOME");
if (java_home) {
+ BD_DEBUG(DBG_BDJ, "Using JAVA_HOME '%s'\n", java_home);
*p_java_home = java_home;
return _jvm_dlopen_a(java_home, jvm_dir, num_jvm_dir, jvm_lib);
}
#if defined(_WIN32) && !defined(HAVE_BDJ_J2ME)
+ /* Try Windows registry */
handle = _load_jvm_win32(p_java_home);
if (handle) {
return handle;
@@ -868,7 +870,7 @@ static const char * const java_base_exports[] = {
};
static const size_t num_java_base_exports = sizeof(java_base_exports) / sizeof(java_base_exports[0]);
-static int _create_jvm(void *jvm_lib, const char *java_home, const char *jar_file[2],
+static int _create_jvm(void *jvm_lib, const char *java_home, BDJ_CONFIG *cfg,
JNIEnv **env, JavaVM **jvm)
{
(void)java_home; /* used only with J2ME */
@@ -915,10 +917,10 @@ static int _create_jvm(void *jvm_lib, const char *java_home, const char *jar_fil
if (!java_9) {
option[n++].optionString = str_dup ("-Djavax.accessibility.assistive_technologies= ");
- option[n++].optionString = str_printf("-Xbootclasspath/p:" CLASSPATH_FORMAT_P, jar_file[0], jar_file[1]);
+ option[n++].optionString = str_printf("-Xbootclasspath/p:" CLASSPATH_FORMAT_P, cfg->classpath[0], cfg->classpath[1]);
} else {
- option[n++].optionString = str_printf("--patch-module=java.base=%s", jar_file[0]);
- option[n++].optionString = str_printf("--patch-module=java.desktop=%s", jar_file[1]);
+ option[n++].optionString = str_printf("--patch-module=java.base=%s", cfg->classpath[0]);
+ option[n++].optionString = str_printf("--patch-module=java.desktop=%s", cfg->classpath[1]);
/* Fix module graph */
@@ -996,6 +998,7 @@ static int _create_jvm(void *jvm_lib, const char *java_home, const char *jar_fil
BD_DEBUG(DBG_BDJ | DBG_CRIT, "Failed to create new Java VM. JNI_CreateJavaVM result: %d\n", result);
return 0;
}
+ BD_DEBUG(DBG_BDJ , "Created Java VM %p (env %p)\n", (void *)jvm, (void *)*env);
return 1;
}
@@ -1037,9 +1040,8 @@ BDJAVA* bdj_open(const char *path, struct bluray *bd,
JNIEnv* env = NULL;
JavaVM *jvm = NULL;
- const char *jar[2] = { cfg->classpath[0], cfg->classpath[1] };
if (!_find_jvm(jvm_lib, &env, &jvm) &&
- !_create_jvm(jvm_lib, java_home, jar, &env, &jvm)) {
+ !_create_jvm(jvm_lib, java_home, cfg, &env, &jvm)) {
X_FREE(bdjava);
dl_dlclose(jvm_lib);
=====================================
src/util/strutl.c
=====================================
@@ -112,10 +112,13 @@ void str_tolower(char *s)
char *str_print_hex(char *out, const uint8_t *buf, int count)
{
+ static const char nibble[16] = "0123456789abcdef";
int zz;
for (zz = 0; zz < count; zz++) {
- sprintf(out + (zz * 2), "%02x", buf[zz]);
+ out[zz*2 ] = nibble[(buf[zz] >> 4) & 0xf];
+ out[zz*2 + 1] = nibble[buf[zz] & 0x0f];
}
+ out[zz*2] = 0;
return out;
}
View it on GitLab: https://code.videolan.org/videolan/libbluray/-/compare/7aae20a6a1660e2ed2d13246ea511809489cc25c...02141b8bb58bfb292c982a544bcf884140ff0c01
--
View it on GitLab: https://code.videolan.org/videolan/libbluray/-/compare/7aae20a6a1660e2ed2d13246ea511809489cc25c...02141b8bb58bfb292c982a544bcf884140ff0c01
You're receiving this email because of your account on code.videolan.org.
More information about the libbluray-devel
mailing list