소스 검색

Fix buffer overflow in generate_enc_password with increase rsalt by 2 (#1463)

before this change i see a bufferflow during `readable_string`.
Stefan Junker 1 년 전
부모
커밋
158fe9b698
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      src/client/ns_turn_msg.c

+ 2 - 1
src/client/ns_turn_msg.c

@@ -292,8 +292,9 @@ static void readable_string(unsigned char *orig, unsigned char *out, size_t sz)
   out[0] = 0;
 
   for (i = 0; i < sz; ++i) {
-    snprintf((char *)(out + (i * 2)), 4, "%02x", (unsigned int)orig[i]);
+    snprintf((char *)(out + (i * 2)), 3, "%02x", (unsigned int)orig[i]);
   }
+  out[sz * 2] = 0;
 }
 
 static void generate_enc_password(const char *pwd, char *result, const unsigned char *orig_salt) {