Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix device name validation in "modelstore" command#884

Merged
alonre24 merged 2 commits into
masterfrom
fix_device_validation
Dec 1, 2021
Merged

Fix device name validation in "modelstore" command#884
alonre24 merged 2 commits into
masterfrom
fix_device_validation

Conversation

@alonre24

Copy link
Copy Markdown
Collaborator

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 replaces sscanf with strtoll in parseDeviceStr, to have safe exit in case of invalid device id string in these commands.

@alonre24 alonre24 requested a review from DvirDukhan November 30, 2021 17:58
@codecov

codecov Bot commented Nov 30, 2021

Copy link
Copy Markdown

Codecov Report

Merging #884 (045a7fe) into master (0390451) will increase coverage by 0.02%.
The diff coverage is 63.15%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
src/backends/util.c 33.33% <30.00%> (-5.13%) ⬇️
src/redis_ai_objects/tensor.c 91.97% <100.00%> (+0.04%) ⬆️
src/redisai.c 87.79% <100.00%> (+0.42%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e553c6...045a7fe. Read the comment docs.

@DvirDukhan DvirDukhan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where was the 5th character did not validated?
anyway, looks good

Comment thread src/redisai.c
strlen(devicestr) <= 10) {
} else if ((strncasecmp(devicestr, "GPU:", device_prefix_len) == 0 ||
strncasecmp(devicestr, "CPU:", device_prefix_len) == 0) &&
strlen(devicestr) < 10) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the change from <= to <?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment explaining why this is invalid device

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a comment in lines 28-29 explaining it...

@alonre24 alonre24 merged commit 0aa5085 into master Dec 1, 2021
@alonre24 alonre24 deleted the fix_device_validation branch December 1, 2021 12:17
DvirDukhan pushed a commit that referenced this pull request Jan 5, 2022
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants