Hi Lennart,
This patch seems okay. However,
Can we not achieve the same alternatively as below?
if (attribute != NULL && value != NULL) {
TRACE("attribute %s", attribute->attrName);
.......
.........
} else {
// Comment this out. TRACE("i: %d,
attribute: %d, value: %d", i, attribute == NULL ? 0 : 1
// , value == NULL ? 0 : 1);
If (attribute && !value)
rc = SA_AIS_ERR_INVALID_PARAM;
}
Thanks,
Mathi.
>-----Original Message-----
>From: Lennart Lund [mailto:[email protected]]
>Sent: Tuesday, March 11, 2014 6:30 PM
>To: Mathivanan Naickan Palanivelu
>Cc: [email protected]
>Subject: [PATCH 1 of 1] logsv: Do not allow NULL pointers for string variables
>in
>OI validity check [#771]
>
> osaf/services/saf/logsv/lgs/lgs_imm.c | 20 ++++++++++++--------
> 1 files changed, 12 insertions(+), 8 deletions(-)
>
>
>Return parameter error if user input is a NULL pointer instead of a pointer to
>a
>string
>
>diff --git a/osaf/services/saf/logsv/lgs/lgs_imm.c
>b/osaf/services/saf/logsv/lgs/lgs_imm.c
>--- a/osaf/services/saf/logsv/lgs/lgs_imm.c
>+++ b/osaf/services/saf/logsv/lgs/lgs_imm.c
>@@ -795,31 +795,35 @@ static SaAisErrorT check_attr_validity(S
>
> if (!strcmp(attribute->attrName,
>"saLogStreamFileName")) {
> char *fileName = *((char **) value);
>- if (lgs_check_path_exists_h(fileName) == 0) {
>+ if (fileName == NULL) {
>+ rc = SA_AIS_ERR_INVALID_PARAM;
>+ report_oi_error(immOiHandle,
>opdata->ccbId,
>+ "NULL pointer to
>saLogStreamFileName");
>+ } else if (lgs_check_path_exists_h(fileName)
>== 0) {
> report_oi_error(immOiHandle,
>opdata->ccbId,
> "File %s already exist",
>fileName);
> rc = SA_AIS_ERR_EXIST;
>+ TRACE("fileName: %s", fileName);
> }
>- TRACE("fileName: %s", fileName);
> } else if (!strcmp(attribute->attrName,
>"saLogStreamPathName")) {
>- char fileName[PATH_MAX];
>- n = snprintf(fileName, PATH_MAX,
>"%s//%s//.",
>+ char stream_path[PATH_MAX];
>+ n = snprintf(stream_path, PATH_MAX,
>"%s//%s//.",
> lgs_cb->logsv_root_dir,
> *((char **) value));
> if (n >= PATH_MAX) {
> report_oi_error(immOiHandle,
>opdata->ccbId,
> "Path > PATH_MAX");
> rc = SA_AIS_ERR_BAD_OPERATION;
>- } else if
>(lgs_relative_path_check_ts(fileName)) {
>+ } else if
>(lgs_relative_path_check_ts(stream_path)) {
> report_oi_error(immOiHandle,
>opdata->ccbId,
>- "Path %s not valid",
>fileName);
>+ "Path %s not valid",
>stream_path);
> rc = SA_AIS_ERR_INVALID_PARAM;
> } else if (lgs_check_path_exists_h(lgs_cb-
>>logsv_root_dir) != 0) {
> report_oi_error(immOiHandle,
>opdata->ccbId,
>- "Path %s does not
>exist", fileName);
>+ "Path %s does not
>exist", stream_path);
> rc = SA_AIS_ERR_BAD_OPERATION;
> }
>- TRACE("fileName: %s", fileName);
>+ TRACE("Stream path: %s", stream_path);
> } else if (!strcmp(attribute->attrName,
>"saLogStreamMaxLogFileSize")) {
> SaUint64T maxLogFileSize = *((SaUint64T *)
>value);
> // maxLogFileSize == 0 is interpreted as
>"infinite" size.
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel