Skip to content

Commit

Permalink
Fix hardcoded size check
Browse files Browse the repository at this point in the history
We initially hardcoded a size check here due to C++ 11 weirdness.
However, there is appearently a nicer way to solve this.
Source: http://stackoverflow.com/questions/3718910/can-i-get-the-size-of-a-struct-field-w-o-creating-an-instance-of-the-struct
  • Loading branch information
malexmave committed Dec 15, 2016
1 parent 56ba1c4 commit 864594e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion nfcd/src/main/jni/javainterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ JNIEXPORT void JNICALL Java_tud_seemuh_nfcgate_xposed_Native_setEnabled(JNIEnv*
JNIEXPORT void JNICALL Java_tud_seemuh_nfcgate_xposed_Native_uploadConfiguration(JNIEnv* env, jobject javaThis, jbyte atqa, jbyte sak, jbyteArray _hist, jbyteArray _uid) {
jsize uid_len = env->GetArrayLength(_uid);
jsize hist_len = env->GetArrayLength(_hist);
if(uid_len > (sizeof(uint8_t) * 64) || hist_len > (sizeof(uint8_t) * 64)) {
if(uid_len > sizeof(s_chip_config().uid) || hist_len > sizeof(s_chip_config().hist)) {
jclass Exception = env->FindClass("java/lang/Exception");
env->ThrowNew(Exception, "uid or hist bigger than buffer");
}
Expand Down

0 comments on commit 864594e

Please sign in to comment.