Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
10e76f9a
Commit
10e76f9a
authored
Jan 09, 2014
by
Eric Cano
Browse files
Fixed improper use of readlink which does not add the trainling \0.
Adapted the unit test which did not simulate this behavior.
parent
467445bd
Changes
2
Hide whitespace changes
Inline
Side-by-side
castor/tape/tapeserver/SCSI/Device.cpp
View file @
10e76f9a
...
...
@@ -215,8 +215,10 @@ SCSI::DeviceInfo SCSI::DeviceVector::getDeviceInfo(const char * path) {
{
char
rl
[
PATH_MAX
];
std
::
string
lp
=
ret
.
sysfs_entry
+
"/generic"
;
if
(
-
1
==
m_sysWrapper
.
readlink
(
lp
.
c_str
(),
rl
,
sizeof
(
rl
)))
ssize_t
rlSize
;
if
(
-
1
==
(
rlSize
=
m_sysWrapper
.
readlink
(
lp
.
c_str
(),
rl
,
sizeof
(
rl
)
-
1
)))
throw
exceptions
::
Errnum
(
"Could not read link "
+
lp
);
rl
[
rlSize
]
=
'\0'
;
std
::
string
gl
(
rl
);
size_t
pos
=
gl
.
find_last_of
(
"/"
);
if
(
pos
==
std
::
string
::
npos
)
...
...
castor/tape/tapeserver/system/Wrapper.cpp
View file @
10e76f9a
...
...
@@ -76,7 +76,11 @@ int System::fakeWrapper::readlink(const char* path, char* buf, size_t len) {
return
-
1
;
}
const
std
::
string
&
link
=
m_links
[
std
::
string
(
path
)];
strncpy
(
buf
,
link
.
c_str
(),
len
);
/* Copy the link without the training \0 as it is the behavior
of the real readlink */
size_t
lenToCopy
=
link
.
size
();
if
(
lenToCopy
>
len
)
lenToCopy
=
len
;
link
.
copy
(
buf
,
lenToCopy
);
return
len
>
link
.
size
()
?
link
.
size
()
:
len
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment