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
mpim-sw
libcdi
Commits
e6630d8d
Commit
e6630d8d
authored
Jul 07, 2020
by
Uwe Schulzweida
Browse files
cdiInqKeyString: set string[maxlength-1] = '\0'
parent
c1095b0c
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/cdi_key.c
View file @
e6630d8d
...
@@ -662,10 +662,12 @@ int cdiInqKeyString(int cdiID, int varID, int key, char *string, int *length)
...
@@ -662,10 +662,12 @@ int cdiInqKeyString(int cdiID, int varID, int key, char *string, int *length)
xassert
(
string
!=
NULL
);
xassert
(
string
!=
NULL
);
xassert
(
length
!=
NULL
);
xassert
(
length
!=
NULL
);
string
[
0
]
=
'\0'
;
int
maxlength
=
*
length
;
if
(
maxlength
>
0
)
string
[
0
]
=
'\0'
;
int
status
=
cdiInqKeyBytes
(
cdiID
,
varID
,
key
,
(
unsigned
char
*
)
string
,
length
);
int
status
=
cdiInqKeyBytes
(
cdiID
,
varID
,
key
,
(
unsigned
char
*
)
string
,
length
);
if
(
status
!=
CDI_NOERR
)
*
length
=
0
;
if
(
status
!=
CDI_NOERR
)
*
length
=
0
;
else
string
[
maxlength
-
1
]
=
'\0'
;
return
status
;
return
status
;
}
}
...
...
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