From kde-commits Mon Feb 23 12:25:58 2004 From: Michael Goffioul Date: Mon, 23 Feb 2004 12:25:58 +0000 To: kde-commits Subject: kdelibs/kdeprint/cups Message-Id: <20040223122558.DF0719953 () office ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=107753916529840 CVS commit by goffioul: Use global variable to store password string (bug #75411) CCMAIL: 75411-done@bugs.kde.org M +12 -0 cupsdoprint.c 1.9 --- kdelibs/kdeprint/cups/cupsdoprint.c #1.8:1.9 @@ -113,6 +113,11 @@ const char* getPasswordCB(const char* pr { *c = '\0'; + /* retrieve password sequence number */ pwd_asked = atoi( ++c ); + /* update CUPS with current username */ cupsSetUser( _user ); + /* copy password to a non temporary location */ + strlcpy( passwd, _passwd, BUFSIZE2 ); + _passwd = passwd; } else @@ -126,4 +131,8 @@ const char* getPasswordCB(const char* pr return NULL; + /* erase buffer containing unencrypted password, for security */ + memset( buf, 0, 256 ); + + /* if OK, _passwd should point to global passwd variable, otherwise it should be NULL */ return _passwd; } @@ -236,4 +245,7 @@ int main(int argc, char* argv[]) /* print files */ jobID = cupsPrintFiles(printer, num_files, files, jobname, num_options, options); + /* erase unemcrypted password for security */ + memset( passwd, 0, BUFSIZE2 ); + /* check job creation status */ if (jobID <= 0) error(ippErrorString(cupsLastError()));