wooksong / contributon2019-nns

7 stars 6 forks source link

[Tests/Sink] Casting from unsigned to signed is dangerous #17

Closed wooksong closed 5 years ago

wooksong commented 5 years ago

In ./tests/nnstreamer_sink/unittest_sink.cpp, the variable, num_buffers, in the struct TestOption is treated as int. It is very dangerous.

For example,

 444   switch (option.test_type) {                                                   
 445     case TEST_TYPE_VIDEO_RGB:                                                   
 446       /** video 160x120 RGB */                                                  
 447       str_pipeline =                                                            
 448           g_strdup_printf                                                       
 449           ("videotestsrc num-buffers=%d ! videoconvert ! video/x-raw,width=160,height=120,format=RGB,framerate=(fraction)30/1 ! "
 450           "tensor_converter ! tensor_sink name=test_sink", option.num_buffers); 
 451       break;                                      

could we guarantee that this code would work as we intended?

wooksong commented 5 years ago
  num-buffers         : Number of buffers to output before sending EOS (-1 = unlimited)
                        flags: readable, writable
                        Integer. Range: -1 - 2147483647 Default: -1 
niklasjang commented 5 years ago

https://github.com/nnsuite/nnstreamer/pull/1758

reference에서 num-buffers 변수 타입 확인하고 guint를 gint로 바꾸었습니다. buffer_index 변수도 num-buffers와 비교 구문이 있어서 똑같이 gint로 바꾸어 주었습니다.

아직 PR 결과 기다리고 있습니다.

wooksong commented 5 years ago

Merged!