-
Notifications
You must be signed in to change notification settings - Fork 123
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
Augeas add lenspath to errormessage #3286
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -111,12 +111,17 @@ int elektraAugeasGenConf (KeySet * ks, Key * errorKey ELEKTRA_UNUSED) | |||||||||||||||||||||||||||
return retval; | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
static const char * getAugeasError (augeas * augeasHandle) | ||||||||||||||||||||||||||||
static const char * getAugeasError (augeas * augeasHandle, const char * lensPath) | ||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||
const char * reason = 0; | ||||||||||||||||||||||||||||
if (aug_error (augeasHandle) != 0) | ||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||
const char * format = "%s\n\tlensPath: %s"; | ||||||||||||||||||||||||||||
reason = aug_error_message (augeasHandle); | ||||||||||||||||||||||||||||
size_t messageSize = strlen (reason) + strlen (lensPath) + strlen (format); | ||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I know
I think you need an additional byte for the terminating
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have copied this from here: libelektra/src/plugins/augeas/augeas.c Lines 143 to 150 in e747336
This bug should then also appear there There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think you are right. The off-by-one error is also one of the reasons why libelektra/src/libs/elektra/internal.c Lines 369 to 371 in f3460ca
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kodebach can you take a look here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What exactly should I look at? @sanssecours is right in general, but actually the I didn't check the second one. It might be more problematic, because in the PS If someone is working on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I did not think about that 😊. Thank you for the detailed explanation. |
||||||||||||||||||||||||||||
char * buffer = elektraMalloc (messageSize); | ||||||||||||||||||||||||||||
snprintf (buffer, messageSize, format, reason, lensPath); | ||||||||||||||||||||||||||||
reason = buffer; | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||
|
@@ -408,7 +413,7 @@ static int saveTree (augeas * augeasHandle, KeySet * ks, const char * lensPath, | |||||||||||||||||||||||||||
if (ret < 0) | ||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||
/* report the augeas specific error */ | ||||||||||||||||||||||||||||
ELEKTRA_SET_VALIDATION_SYNTACTIC_ERROR (parentKey, getAugeasError (augeasHandle)); | ||||||||||||||||||||||||||||
ELEKTRA_SET_VALIDATION_SYNTACTIC_ERROR (parentKey, getAugeasError (augeasHandle, lensPath)); | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
return ret; | ||||||||||||||||||||||||||||
|
@@ -504,7 +509,7 @@ int elektraAugeasGet (Plugin * handle, KeySet * returned, Key * parentKey) | |||||||||||||||||||||||||||
if (ret < 0) | ||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||
fclose (fh); | ||||||||||||||||||||||||||||
ELEKTRA_SET_INSTALLATION_ERROR (parentKey, getAugeasError (augeasHandle)); | ||||||||||||||||||||||||||||
ELEKTRA_SET_INSTALLATION_ERROR (parentKey, getAugeasError (augeasHandle, lensPath)); | ||||||||||||||||||||||||||||
errno = errnosave; | ||||||||||||||||||||||||||||
return -1; | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
|
@@ -536,7 +541,7 @@ int elektraAugeasGet (Plugin * handle, KeySet * returned, Key * parentKey) | |||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||
fclose (fh); | ||||||||||||||||||||||||||||
ksDel (append); | ||||||||||||||||||||||||||||
ELEKTRA_SET_INSTALLATION_ERROR (parentKey, getAugeasError (augeasHandle)); | ||||||||||||||||||||||||||||
ELEKTRA_SET_INSTALLATION_ERROR (parentKey, getAugeasError (augeasHandle, lensPath)); | ||||||||||||||||||||||||||||
errno = errnosave; | ||||||||||||||||||||||||||||
return -1; | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
|
@@ -590,7 +595,7 @@ int elektraAugeasSet (Plugin * handle, KeySet * returned, Key * parentKey) | |||||||||||||||||||||||||||
if (ret < 0) | ||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||
fclose (fh); | ||||||||||||||||||||||||||||
ELEKTRA_SET_INSTALLATION_ERROR (parentKey, getAugeasError (augeasHandle)); | ||||||||||||||||||||||||||||
ELEKTRA_SET_INSTALLATION_ERROR (parentKey, getAugeasError (augeasHandle, lensPath)); | ||||||||||||||||||||||||||||
errno = errnosave; | ||||||||||||||||||||||||||||
return -1; | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
|
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 think you can also make the pointer
const
, if you want to.