-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added error check in Getfilecon #584
Conversation
|
||
if err != nil { | ||
return "", err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then probably change the final return to return string(con), nil
in this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hqhq
Updated as per the comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found this function if not used, even when it's first added, ping @rhatdan .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hqhq
There is no caller at this moment for this function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use this function when debugging code, in the past. Do we really need to remove it just because no one is using it currently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, just make sure we know it's there :)
0d780a3
to
0379459
Compare
|
||
if err != nil { | ||
return "", err | ||
} | ||
// Trim the NUL byte at the end of the byte buffer, if present. | ||
if con[len(con)-1] == '\x00' { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the odds of no error and len(con)==0? If possible should probably add a if len(con) check before causing a "panic: runtime error: index out of range"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I agree with this check
Signed-off-by: rajasec <[email protected]> Fixed review comments Signed-off-by: rajasec <[email protected]> Fixed review comments for adding length check Signed-off-by: rajasec <[email protected]> Fixed review comment Signed-off-by: rajasec <[email protected]>
0379459
to
fdbfca6
Compare
if con[len(con)-1] == '\x00' { | ||
con = con[:len(con)-1] | ||
if len(con) > 0 { | ||
if con[len(con)-1] == '\x00' { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's minor, but I think we should change it to if len(con) > 0 && con[len(con)-1] == '\x00'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hqhq
Updated.
fdbfca6
to
039d25c
Compare
LGTM |
Looks good. |
👍 |
LGTM |
Added error check in Getfilecon
…-or-duplicates glossary: Make objects explicitly unordered and forbid duplicate names
This condition landed in 27a05de (Add text about extensions, 2016-06-26, opencontainers#510) with subsequent wording tweaks in 3f0440b (config.md: add empty limit for key of annotations, Dec 28 10:35:19 2016, opencontainers#645) and 2c8feeb (config: Bring "unique... within this map" back together, 2017-01-12, opencontainers#654). However, since eeaccfa (glossary: Make objects explicitly unordered and forbid duplicate names, 2016-09-27, opencontainers#584) we forbid duplicate keys on *all* objects (not just annotations), so this PR removes the redundant annotation-specific condition. Signed-off-by: W. Trevor King <[email protected]>
Added the error check for Getfilecon if it returns an error.
Signed-off-by: rajasec [email protected]