summaryrefslogtreecommitdiffstats
path: root/libkpgp
diff options
context:
space:
mode:
Diffstat (limited to 'libkpgp')
-rw-r--r--libkpgp/kpgp.cpp2
-rw-r--r--libkpgp/kpgpbase.cpp26
2 files changed, 15 insertions, 13 deletions
diff --git a/libkpgp/kpgp.cpp b/libkpgp/kpgp.cpp
index ec80e688..8a9c6898 100644
--- a/libkpgp/kpgp.cpp
+++ b/libkpgp/kpgp.cpp
@@ -1007,7 +1007,7 @@ Module::getKpgp()
{
if (!kpgpObject)
{
- kdError(5100) << "there is no instance of kpgp available" << endl;
+ kpgpObject = new Module();
}
return kpgpObject;
}
diff --git a/libkpgp/kpgpbase.cpp b/libkpgp/kpgpbase.cpp
index fa444be7..157c73e3 100644
--- a/libkpgp/kpgpbase.cpp
+++ b/libkpgp/kpgpbase.cpp
@@ -149,7 +149,8 @@ Base::run( const char *cmd, const char *passphrase, bool onlyReadFromPGP )
if (!onlyReadFromPGP) {
if (!input.isEmpty()) {
// write to pin[1] one line after the other to prevent dead lock
- for (unsigned int i=0; i<input.length(); i+=len2) {
+ uint input_length = input.length();
+ for (unsigned int i=0; i<input_length; i+=len2) {
len2 = 0;
// check if writing now to pin[1] will not block (5 ms timeout)
@@ -164,12 +165,12 @@ Base::run( const char *cmd, const char *passphrase, bool onlyReadFromPGP )
else if (pollin.revents & POLLOUT) {
// search end of next line
if ((len2 = input.find('\n', i)) == -1)
- len2 = input.length()-i;
+ len2 = input_length - i;
else
- len2 = len2-i+1;
+ len2 = len2 - i + 1;
//kdDebug(5100) << "Trying to write " << len2 << " bytes to pin[1] ..." << endl;
- len2 = write(pin[1], input.mid(i,len2).data(), len2);
+ len2 = write(pin[1], input.data() + i, len2);
//kdDebug(5100) << "Wrote " << len2 << " bytes to pin[1] ..." << endl;
}
}
@@ -353,7 +354,7 @@ Base::run( const char *cmd, const char *passphrase, bool onlyReadFromPGP )
if (WIFEXITED(childExitStatus) != 0) {
// Get the return code of the child
childExitStatus = WEXITSTATUS(childExitStatus);
- kdDebug(5100) << "PGP exited with exit status " << childExitStatus
+ kdDebug(5100) << "PGP exited with exit status " << childExitStatus
<< endl;
}
else {
@@ -524,6 +525,7 @@ Base::runGpg( const char *cmd, const char *passphrase, bool onlyReadFromGnuPG )
pid_t waitpidRetVal;
unsigned int input_pos = 0;
+ uint input_length = input.length();
do {
//kdDebug(5100) << "Checking if GnuPG is still running..." << endl;
@@ -585,7 +587,7 @@ Base::runGpg( const char *cmd, const char *passphrase, bool onlyReadFromGnuPG )
// disable polling of stderr
poller[STD_ERR].events = 0;
}
-
+
if (num_pollers > 2) {
if (poller[STD_IN].revents & ( POLLERR | POLLHUP ) ) {
kdDebug(5100) << "GnuPG seems to have hung up" << endl;
@@ -597,17 +599,17 @@ Base::runGpg( const char *cmd, const char *passphrase, bool onlyReadFromGnuPG )
if (!input.isEmpty()) {
// search end of next line
if ((len2 = input.find('\n', input_pos)) == -1)
- len2 = input.length()-input_pos;
+ len2 = input_length - input_pos;
else
- len2 = len2-input_pos+1;
+ len2 = len2 - input_pos + 1;
//kdDebug(5100) << "Trying to write " << len2 << " bytes to pin[1] ..." << endl;
- len2 = write(pin[1], input.mid(input_pos,len2).data(), len2);
+ len2 = write(pin[1], input.data() + input_pos, len2 );
//kdDebug(5100) << "Wrote " << len2 << " bytes to pin[1] ..." << endl;
input_pos += len2;
// We are done.
- if (input_pos >= input.length()) {
+ if (input_pos >= input_length) {
//kdDebug(5100) << "All input was written to pin[1]" << endl;
close (pin[1]);
pin[1] = -1;
@@ -635,7 +637,7 @@ Base::runGpg( const char *cmd, const char *passphrase, bool onlyReadFromGnuPG )
} while(waitpidRetVal == 0);
if( 0 <= pin[1] )
- close (pin[1]);
+ close (pin[1]);
close(pout[0]);
close(perr[0]);
@@ -646,7 +648,7 @@ Base::runGpg( const char *cmd, const char *passphrase, bool onlyReadFromGnuPG )
if (WIFEXITED(childExitStatus) != 0) {
// Get the return code of the child
childExitStatus = WEXITSTATUS(childExitStatus);
- kdDebug(5100) << "GnuPG exited with exit status " << childExitStatus
+ kdDebug(5100) << "GnuPG exited with exit status " << childExitStatus
<< endl;
}
else {