Skip to content

Commit

Permalink
Fix deprecations and other warnings reported by coverity
Browse files Browse the repository at this point in the history
  • Loading branch information
schwabe committed Jun 1, 2023
1 parent dab8793 commit 720f827
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.IOException;
import java.io.StringReader;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.*;
Expand Down Expand Up @@ -66,7 +67,7 @@ private String hashConfig(String rawconfig) {
MessageDigest digest;
try {
digest = MessageDigest.getInstance("SHA1");
byte[] utf8_bytes = config.getBytes();
byte[] utf8_bytes = config.getBytes(StandardCharsets.UTF_8);
digest.update(utf8_bytes, 0, utf8_bytes.length);
return new BigInteger(1, digest.digest()).toString(16);
} catch (NoSuchAlgorithmException e) {
Expand Down
3 changes: 2 additions & 1 deletion main/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
Expand Down Expand Up @@ -135,7 +136,7 @@ private void startOpenVPNThreadArgs(String[] argv) {

InputStream in = mProcess.getInputStream();
OutputStream out = mProcess.getOutputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(in));
BufferedReader br = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));

mOutputStream = out;
mStreamFuture.run();
Expand Down
6 changes: 3 additions & 3 deletions main/src/ui/java/de/blinkt/openvpn/fragments/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ object Utils {
if ("insecure".equals(vp.mTlSCertProfile))
warnings.add("low security (TLS security profile 'insecure' selected)");

var cipher= vp.mCipher?.toUpperCase(Locale.ROOT)
if (cipher.isNullOrEmpty())
var cipher= vp.mCipher.uppercase(Locale.ROOT)
if (cipher.isEmpty())
cipher = "BF-CBC";

for (weakCipher in weakCiphers) {
if ((vp.mDataCiphers != null && vp.mDataCiphers.toUpperCase(Locale.ROOT)
if ((vp.mDataCiphers != null && vp.mDataCiphers.uppercase(Locale.ROOT)
.contains(weakCipher))
|| (vp.mCompatMode in 1..20399 && (cipher == weakCipher))
)
Expand Down
4 changes: 2 additions & 2 deletions runcoverity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ cov-configure --config .coverity/cfg.xml --kotlin
cov-configure --config .coverity/cfg.xml --java

./gradlew -b build.gradle.kts --no-daemon clean
cov-build --dir .coverity/idir --config .coverity/cfg.xml ./gradlew -b build.gradle.kts --no-daemon assembleUiRelease
cov-build --dir .coverity/idir --config .coverity/cfg.xml ./gradlew -b build.gradle.kts --no-daemon assembleUiOvpn23Release

NDK_VER=${NDK_VER:-25.1.8937393}
NDK_VER=${NDK_VER:-25.2.9519653}
cov-analyze --dir .coverity/idir --all --strip-path ${PWD}/main/src/main/cpp --strip-path ${PWD}/main/src --strip-path ${PWD} --strip-path ${ANDROID_HOME}/ndk/${NDK_VER}/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/ --strip-path ${ANDROID_HOME}/ndk/${NDK_VER}/toolchains/llvm/prebuilt/linux-x86_64/sysroot

cov-commit-defects --dir .coverity/idir --ssl -host ${COVERITY_CONNECT_HOST} --stream icsopenvpn-styx-master --auth-key-file ~/.coverity/auth-key.txt

0 comments on commit 720f827

Please sign in to comment.