summaryrefslogtreecommitdiff
path: root/noncore/apps
Unidiff
Diffstat (limited to 'noncore/apps') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/Bkmks.cpp1
-rw-r--r--noncore/apps/opie-sheet/Excel.cpp4
-rw-r--r--noncore/apps/zsafe/zsafe.cpp45
3 files changed, 27 insertions, 23 deletions
diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp
index 00141a3..45aa045 100644
--- a/noncore/apps/opie-reader/Bkmks.cpp
+++ b/noncore/apps/opie-reader/Bkmks.cpp
@@ -340,12 +340,13 @@ Bkmk* BkmkFile::read05(BkmkFile* /*_this*/, FILE* f)
340 tchar* anno = new tchar[ln+1]; 340 tchar* anno = new tchar[ln+1];
341 if (ln > 0) fread(anno,sizeof(tchar),ln,f); 341 if (ln > 0) fread(anno,sizeof(tchar),ln,f);
342 anno[ln] = 0; 342 anno[ln] = 0;
343 unsigned int pos; 343 unsigned int pos;
344 fread(&pos,sizeof(pos),1,f); 344 fread(&pos,sizeof(pos),1,f);
345 b = new Bkmk(nm,anno,pos); 345 b = new Bkmk(nm,anno,pos);
346 delete [] anno;
346 } 347 }
347 } 348 }
348 return b; 349 return b;
349} 350}
350 351
351Bkmk* BkmkFile::read06(BkmkFile* /*_this*/, FILE* f) 352Bkmk* BkmkFile::read06(BkmkFile* /*_this*/, FILE* f)
diff --git a/noncore/apps/opie-sheet/Excel.cpp b/noncore/apps/opie-sheet/Excel.cpp
index 51fe707..27080e9 100644
--- a/noncore/apps/opie-sheet/Excel.cpp
+++ b/noncore/apps/opie-sheet/Excel.cpp
@@ -374,13 +374,15 @@ ExcelBREC* ExcelBook::PeekBREC(void)
374}; 374};
375 375
376char* ExcelBook::GetDataOfBREC(ExcelBREC* record) 376char* ExcelBook::GetDataOfBREC(ExcelBREC* record)
377{ 377{
378 if(record->data==NULL) 378 if(record->data==NULL)
379 { 379 {
380 ConvertCharToArray(record,Read(record->position,record->length),record->length); 380 char* readData = Read(record->position,record->length);
381 ConvertCharToArray(record,readData,record->length);
382 delete [] readData;
381 }; 383 };
382 return record->data;//new? 384 return record->data;//new?
383}; 385};
384 386
385void ExcelBook::ConvertCharToArray(ExcelBREC* record, char* chars, int length) 387void ExcelBook::ConvertCharToArray(ExcelBREC* record, char* chars, int length)
386{ 388{
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp
index f70f863..9c0c6ce 100644
--- a/noncore/apps/zsafe/zsafe.cpp
+++ b/noncore/apps/zsafe/zsafe.cpp
@@ -1769,14 +1769,16 @@ int ZSafe::loadInit(const char* _filename, const char *password)
1769 fd = fopen (_filename, "rb"); 1769 fd = fopen (_filename, "rb");
1770 1770
1771 QFileInfo f (_filename); 1771 QFileInfo f (_filename);
1772 load_buffer_length = f.size(); 1772 load_buffer_length = f.size();
1773 load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2; 1773 load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2;
1774 1774
1775 if (fd == NULL) 1775 if (fd == NULL) {
1776 delete krc2;
1776 return PWERR_OPEN; 1777 return PWERR_OPEN;
1778 }
1777 1779
1778 buffer = (char *)malloc(load_buffer_length); 1780 buffer = (char *)malloc(load_buffer_length);
1779 for (j = 0; password[j] != '\0'; j++) { 1781 for (j = 0; password[j] != '\0'; j++) {
1780 key[j] = password[j]; 1782 key[j] = password[j];
1781 } 1783 }
1782 keylength = j; 1784 keylength = j;
@@ -1785,14 +1787,16 @@ int ZSafe::loadInit(const char* _filename, const char *password)
1785#ifndef Q_WS_WIN 1787#ifndef Q_WS_WIN
1786 size = read(fileno (fd), (unsigned char *) (charbuf + count), 8); 1788 size = read(fileno (fd), (unsigned char *) (charbuf + count), 8);
1787#else 1789#else
1788 size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); 1790 size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd);
1789#endif 1791#endif
1790 1792
1791 if (size < 8) 1793 if (size < 8) {
1794 delete krc2;
1792 return PWERR_DATA; 1795 return PWERR_DATA;
1796 }
1793 1797
1794 for (count = 0; count < 4; count++) { 1798 for (count = 0; count < 4; count++) {
1795 count2 = count << 1; 1799 count2 = count << 1;
1796 iv[count] = charbuf[count2] << 8; 1800 iv[count] = charbuf[count2] << 8;
1797 iv[count] += charbuf[count2 + 1]; 1801 iv[count] += charbuf[count2 + 1];
1798 } 1802 }
@@ -1806,12 +1810,13 @@ int ZSafe::loadInit(const char* _filename, const char *password)
1806#else 1810#else
1807 while ((count = fread ((unsigned char *) (charbuf), sizeof(unsigned char), 8, fd)) > 0) { 1811 while ((count = fread ((unsigned char *) (charbuf), sizeof(unsigned char), 8, fd)) > 0) {
1808 while (count < 8) { 1812 while (count < 8) {
1809 count2 = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); 1813 count2 = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd);
1810#endif 1814#endif
1811 if (count2 == 0) { 1815 if (count2 == 0) {
1816 delete krc2;
1812 return PWERR_DATA; 1817 return PWERR_DATA;
1813 } 1818 }
1814 count += count2; 1819 count += count2;
1815 } /* while (count < 8) */ 1820 } /* while (count < 8) */
1816 1821
1817 size += 8; 1822 size += 8;
@@ -1826,12 +1831,13 @@ int ZSafe::loadInit(const char* _filename, const char *password)
1826 1831
1827 krc2->rc2_decrypt (plaintext); 1832 krc2->rc2_decrypt (plaintext);
1828 memcpy ((unsigned char *) (buffer + bufferIndex), plaintext, 8); 1833 memcpy ((unsigned char *) (buffer + bufferIndex), plaintext, 8);
1829 bufferIndex += 8; 1834 bufferIndex += 8;
1830 buffer[bufferIndex + 1] = '\0'; 1835 buffer[bufferIndex + 1] = '\0';
1831 } /* while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) */ 1836 } /* while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) */
1837 delete krc2;
1832 size -= buffer[size - 1]; 1838 size -= buffer[size - 1];
1833 lastcount = 0; 1839 lastcount = 0;
1834 1840
1835 /* This will point to the starting index */ 1841 /* This will point to the starting index */
1836 bufferIndex = 0; 1842 bufferIndex = 0;
1837 return PWERR_GOOD; 1843 return PWERR_GOOD;
@@ -2096,43 +2102,31 @@ int ZSafe::saveInit(const char *_filename, const char *password)
2096 unsigned int j = 0; 2102 unsigned int j = 0;
2097 unsigned int keylength; 2103 unsigned int keylength;
2098 // int val; 2104 // int val;
2099 int count2; 2105 int count2;
2100 Krc2* krc2 = new Krc2(); 2106 Krc2* krc2 = new Krc2();
2101 2107
2102 /* first we should check the permissions of the filename */
2103/*
2104 if (QFile::exists(_filename)) {
2105 val = checkFile(_filename);
2106 if (val != PWERR_GOOD)
2107 return val;
2108 } else
2109 {
2110 val = creat (_filename, (S_IRUSR | S_IWUSR));
2111 if (val == -1)
2112 return PWERR_OPEN;
2113 else
2114 close(val);
2115 }
2116*/
2117 QFileInfo f (_filename); 2108 QFileInfo f (_filename);
2118 save_buffer_length = f.size(); 2109 save_buffer_length = f.size();
2119 save_buffer_length = ((save_buffer_length / 1024)+1) * 1024; 2110 save_buffer_length = ((save_buffer_length / 1024)+1) * 1024;
2120 2111
2121 fd = fopen (_filename, "wb"); 2112 fd = fopen (_filename, "wb");
2122 if (fd == NULL) 2113 if (fd == NULL) {
2114 delete krc2;
2123 return PWERR_OPEN; 2115 return PWERR_OPEN;
2116 }
2124 2117
2125 buffer = (char*)malloc(save_buffer_length); 2118 buffer = (char*)malloc(save_buffer_length);
2126 2119
2127 /* make the key ready */ 2120 /* make the key ready */
2128 for (j = 0; password[j] != '\0'; j++) { 2121 for (j = 0; password[j] != '\0'; j++) {
2129 key[j] = password[j]; 2122 key[j] = password[j];
2130 } 2123 }
2131 keylength = j; 2124 keylength = j;
2132 krc2->rc2_expandkey (key, keylength, 128); 2125 krc2->rc2_expandkey (key, keylength, 128);
2126 delete krc2;
2133 2127
2134 /* First, we make the IV */ 2128 /* First, we make the IV */
2135 for (count2 = 0; count2 < 4; count2++) { 2129 for (count2 = 0; count2 < 4; count2++) {
2136 iv[count2] = rand (); 2130 iv[count2] = rand ();
2137 putc ((unsigned char) (iv[count2] >> 8), fd); 2131 putc ((unsigned char) (iv[count2] >> 8), fd);
2138 putc ((unsigned char) (iv[count2] & 0xff), fd); 2132 putc ((unsigned char) (iv[count2] & 0xff), fd);
@@ -2185,21 +2179,27 @@ int ZSafe::saveEntry(char *entry[FIELD_SIZE])
2185 2179
2186 /* Now store the ciphertext as the iv */ 2180 /* Now store the ciphertext as the iv */
2187 iv[count3] = plaintext[count3]; 2181 iv[count3] = plaintext[count3];
2188 2182
2189 /* reset the buffer index */ 2183 /* reset the buffer index */
2190 bufferIndex = 0; 2184 bufferIndex = 0;
2191 if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) return PWERR_DATA; 2185 if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) {
2192 if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) return PWERR_DATA; 2186 delete krc2;
2187 return PWERR_DATA;
2188 }
2189 if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) {
2190 delete krc2;
2191 return PWERR_DATA;
2192 }
2193 } /*for (count3 = 0; count3 < 5; count3++)*/ 2193 } /*for (count3 = 0; count3 < 5; count3++)*/
2194 } /*if (bufferIndex == 5)*/ 2194 } /*if (bufferIndex == 5)*/
2195 /* increment a short, not a byte */ 2195 /* increment a short, not a byte */
2196 count2 += 2; 2196 count2 += 2;
2197 } /*while (count2 < strlen (buffer))*/ 2197 } /*while (count2 < strlen (buffer))*/
2198 int ret = PWERR_GOOD; 2198 delete krc2;
2199 return ret; 2199 return PWERR_GOOD;
2200} 2200}
2201 2201
2202int ZSafe::saveFinalize(void) 2202int ZSafe::saveFinalize(void)
2203{ 2203{
2204 int count1, retval = PWERR_GOOD; 2204 int count1, retval = PWERR_GOOD;
2205 unsigned short ciphertext[4]; 2205 unsigned short ciphertext[4];
@@ -2225,12 +2225,13 @@ int ZSafe::saveFinalize(void)
2225 if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; 2225 if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA;
2226 if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; 2226 if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA;
2227 } 2227 }
2228 2228
2229 fclose (fd); 2229 fclose (fd);
2230 free(buffer); 2230 free(buffer);
2231 delete krc2;
2231 return retval; 2232 return retval;
2232} 2233}
2233 2234
2234void ZSafe::quitMe () 2235void ZSafe::quitMe ()
2235{ 2236{
2236 if (modified) 2237 if (modified)