Fix device name validation in "modelstore" command#884
Conversation
Codecov Report
@@ Coverage Diff @@
## master #884 +/- ##
==========================================
+ Coverage 81.21% 81.24% +0.02%
==========================================
Files 54 54
Lines 8145 8152 +7
==========================================
+ Hits 6615 6623 +8
+ Misses 1530 1529 -1
Continue to review full report at Codecov.
|
DvirDukhan
left a comment
There was a problem hiding this comment.
where was the 5th character did not validated?
anyway, looks good
| strlen(devicestr) <= 10) { | ||
| } else if ((strncasecmp(devicestr, "GPU:", device_prefix_len) == 0 || | ||
| strncasecmp(devicestr, "CPU:", device_prefix_len) == 0) && | ||
| strlen(devicestr) < 10) { |
There was a problem hiding this comment.
No actual reason... I believe that 5 digits should be enough
| 'AI.MODELSTORE', 'm{1}', 'TORCH', 'CPU::', 'BLOB', model_pb) | ||
| check_error_message(env, con, "Invalid DEVICE", | ||
| 'AI.MODELSTORE', 'm{1}', 'TORCH', 'CPU:1.8', 'BLOB', model_pb) | ||
| check_error_message(env, con, "Invalid DEVICE", |
There was a problem hiding this comment.
add a comment explaining why this is invalid device
There was a problem hiding this comment.
There is a comment in lines 28-29 explaining it...
* Merge pull request #892 from RedisAI/tflite_avoid_magic_numbers avoid magic numbers in tflite * Merge pull request #891 from RedisAI/validate_runqueue_upon_restart create runqueue upon model and script loading * Merge pull request #888 from RedisAI/pytorch_1_10 updated pytorch and cuda version * Removed Xenial (#893) * Merge pull request #894 from RedisAI/set_cluster_timeout_on_env_reset added 120 seconds timeout for env restart and reload * Fix device name validation in "modelstore" command (#884) * 1.2.6 version bump Co-authored-by: Chayim <[email protected]> Co-authored-by: alonre24 <[email protected]>
The fifth character was not validated.
Also, for scriptstore and the deprecated modelset and scriptset, the only validation occurs in
parseDeviceStr(which is from within the backends, after parsing stage). This PR replacessscanfwithstrtollinparseDeviceStr, to have safe exit in case of invalid device id string in these commands.