summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcybjit <cybjit@gmail.com>2014-05-10 20:50:31 +0200
committercybjit <cybjit@gmail.com>2014-05-10 21:29:52 +0200
commit7836f4648f6fb63e1936cdded8fed51ee98471ed (patch)
treed159fba03613fa057c0885a57d1c14d1b4fb9309
parent4eb4cc11104661ada870ca5fca21cb33cd6e1610 (diff)
downloadfribid-7836f4648f6fb63e1936cdded8fed51ee98471ed.tar.gz
fribid-7836f4648f6fb63e1936cdded8fed51ee98471ed.tar.bz2
fribid-7836f4648f6fb63e1936cdded8fed51ee98471ed.zip
handle pipe error
found with clang scan-build ipc.c:101:5: warning: Function call argument is an uninitialized value pipe_sendCommand(pipeinfo->out, command); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-rw-r--r--plugin/ipc.c34
-rw-r--r--plugin/plugin.h4
2 files changed, 25 insertions, 13 deletions
diff --git a/plugin/ipc.c b/plugin/ipc.c
index beb3b69..c6dbcb7 100644
--- a/plugin/ipc.c
+++ b/plugin/ipc.c
@@ -50,13 +50,13 @@ typedef struct {
pid_t child;
} PipeInfo;
-static void openPipesWithArgs(PipeInfo *pipeinfo, const char *argv[]) {
+BankIDError openPipesWithArgs(PipeInfo *pipeinfo, const char *argv[]) {
int pipeIn[2];
int pipeOut[2];
if (pipe(pipeIn) == -1 || pipe(pipeOut) == -1) {
perror(BINNAME ": Failed to create pipe");
- return;
+ return BIDERR_InternalError;
}
pipeinfo->child = fork();
@@ -83,17 +83,19 @@ static void openPipesWithArgs(PipeInfo *pipeinfo, const char *argv[]) {
pipeinfo->in = fdopen(pipeIn[PIPE_READ_END], "r");
pipeinfo->out = fdopen(pipeOut[PIPE_WRITE_END], "w");
+ return BIDERR_OK;
}
}
-static void openPipes(PipeInfo *pipeinfo, const Plugin *plugin) {
+BankIDError openPipes(PipeInfo *pipeinfo, const Plugin *plugin) {
char windowId[21]; // This holds a native window id (such as an XID)
const char *argv[] = {
mainBinary, ipcOption, windowIdOption, windowId, (char *)NULL,
};
snprintf(windowId, 21, "%ld", plugin->windowId);
- openPipesWithArgs(pipeinfo, argv);
+ BankIDError error = openPipesWithArgs(pipeinfo, argv);
+ return error;
}
static void sendHeader(PipeInfo *pipeinfo, const Plugin *plugin,
@@ -123,7 +125,9 @@ static void closePipes(PipeInfo *pipeinfo) {
char *version_getVersion(Plugin *plugin) {
PipeInfo pipeinfo;
- openPipes(&pipeinfo, plugin);
+ if(openPipes(&pipeinfo, plugin) != BIDERR_OK) {
+ return 0;
+ }
sendHeader(&pipeinfo, plugin, PC_GetVersion);
pipe_finishCommand(pipeinfo.out);
@@ -140,10 +144,12 @@ static void sendSignCommon(PipeInfo *pipeinfo, const Plugin *plugin) {
pipe_sendOptionalString(pipeinfo->out, plugin->info.auth.subjectFilter);
}
-int sign_performAction_Authenticate(Plugin *plugin) {
+BankIDError sign_performAction_Authenticate(Plugin *plugin) {
PipeInfo pipeinfo;
- openPipes(&pipeinfo, plugin);
+ if(openPipes(&pipeinfo, plugin) != BIDERR_OK) {
+ return BIDERR_InternalError;
+ }
sendHeader(&pipeinfo, plugin, PC_Authenticate);
sendSignCommon(&pipeinfo, plugin);
@@ -153,10 +159,12 @@ int sign_performAction_Authenticate(Plugin *plugin) {
return plugin->lastError;
}
-int sign_performAction_Sign(Plugin *plugin) {
+BankIDError sign_performAction_Sign(Plugin *plugin) {
PipeInfo pipeinfo;
- openPipes(&pipeinfo, plugin);
+ if(openPipes(&pipeinfo, plugin) != BIDERR_OK) {
+ return BIDERR_InternalError;
+ }
sendHeader(&pipeinfo, plugin, PC_Sign);
sendSignCommon(&pipeinfo, plugin);
@@ -173,7 +181,9 @@ int sign_performAction_Sign(Plugin *plugin) {
char *regutil_createRequest(Plugin *plugin) {
PipeInfo pipeinfo;
- openPipes(&pipeinfo, plugin);
+ if(openPipes(&pipeinfo, plugin) != BIDERR_OK) {
+ return NULL;
+ }
sendHeader(&pipeinfo, plugin, PC_CreateRequest);
// Send password policy
@@ -214,7 +224,9 @@ char *regutil_createRequest(Plugin *plugin) {
void regutil_storeCertificates(Plugin *plugin, const char *certs) {
PipeInfo pipeinfo;
- openPipes(&pipeinfo, plugin);
+ if(openPipes(&pipeinfo, plugin) != BIDERR_OK) {
+ return;
+ }
sendHeader(&pipeinfo, plugin, PC_StoreCertificates);
pipe_sendOptionalString(pipeinfo.out, certs);
diff --git a/plugin/plugin.h b/plugin/plugin.h
index 30eb97c..6cc8f2e 100644
--- a/plugin/plugin.h
+++ b/plugin/plugin.h
@@ -96,8 +96,8 @@ char *version_getVersion(Plugin *plugin);
char *sign_getParam(Plugin *plugin, const char *name);
bool sign_setParam(Plugin *plugin, const char *name, const char *value);
int sign_performAction(Plugin *plugin, const char *action);
-int sign_performAction_Authenticate(Plugin *plugin);
-int sign_performAction_Sign(Plugin *plugin);
+BankIDError sign_performAction_Authenticate(Plugin *plugin);
+BankIDError sign_performAction_Sign(Plugin *plugin);
void regutil_setParam(Plugin *plugin, const char *name, const char *value);
void regutil_initRequest(Plugin *plugin, const char *type);