~ubuntu-branches/ubuntu/maverick/clamav/maverick-backports

« back to all changes in this revision

Viewing changes to libclamav/uuencode.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Gran, Stephen Gran, Michael Tautschnig
  • Date: 2010-04-26 21:41:18 UTC
  • mfrom: (2.1.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100426214118-i6lo606wnh7ywfj6
Tags: 0.96+dfsg-4
[ Stephen Gran ]
* Fixed typo in clamav-milter's postinst

[ Michael Tautschnig ]
* Fixed typo in clamav-freshclam's postinst (closes: #579271)
* Debconf translation updates
  - Portuguese (closes: #579068)

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include "others.h"
40
40
#include "str.h"
41
41
 
42
 
#ifdef  C_WINDOWS
43
 
#include <io.h>
44
 
#endif
45
 
 
46
42
#include "mbox.h"
47
43
#include "uuencode.h"
48
44
 
50
46
#define RFC2821LENGTH   1000
51
47
 
52
48
int
53
 
cli_uuencode(const char *dir, int desc)
 
49
cli_uuencode(const char *dir, fmap_t *map)
54
50
{
55
 
        FILE *fin;
56
 
        int i;
57
51
        message *m;
58
52
        char buffer[RFC2821LENGTH + 1];
 
53
        size_t at = 0;
59
54
 
60
 
        i = dup(desc);
61
 
        if((fin = fdopen(i, "rb")) == NULL) {
62
 
                cli_errmsg("Can't open descriptor %d\n", desc);
63
 
                close(i);
64
 
                return CL_EOPEN;
65
 
        }
66
 
        if(fgets(buffer, sizeof(buffer) - 1, fin) == NULL) {
 
55
        if(!fmap_gets(map, buffer, &at, sizeof(buffer) - 1)) {
67
56
                /* empty message */
68
 
                fclose(fin);
69
57
                return CL_CLEAN;
70
58
        }
71
59
        if(!isuuencodebegin(buffer)) {
72
 
                fclose(fin);
73
60
                cli_dbgmsg("Message is not in uuencoded format\n");
74
61
                return CL_EFORMAT;
75
62
        }
76
63
 
77
64
        m = messageCreate();
78
65
        if(m == NULL) {
79
 
                fclose(fin);
80
66
                return CL_EMEM;
81
67
        }
82
68
 
83
69
        cli_dbgmsg("found uuencode file\n");
84
70
 
85
 
        if(uudecodeFile(m, buffer, dir, fin) < 0) {
 
71
        if(uudecodeFile(m, buffer, dir, map, &at) < 0) {
86
72
                messageDestroy(m);
87
 
                fclose(fin);
88
73
                cli_dbgmsg("Message is not in uuencoded format\n");
89
74
                return CL_EFORMAT;
90
75
        }
91
76
        messageDestroy(m);
92
77
 
93
 
        fclose(fin);
94
 
 
95
78
        return CL_CLEAN;        /* a lie - but it gets things going */
96
79
}
97
80
 
101
84
 * Return < 0 for failure
102
85
 */
103
86
int
104
 
uudecodeFile(message *m, const char *firstline, const char *dir, FILE *fin)
 
87
uudecodeFile(message *m, const char *firstline, const char *dir, fmap_t *map, size_t *at)
105
88
{
106
89
        fileblob *fb;
107
90
        char buffer[RFC2821LENGTH + 1];
120
103
        cli_dbgmsg("uudecode %s\n", filename);
121
104
        free(filename);
122
105
 
123
 
        while(fgets(buffer, sizeof(buffer) - 1, fin) != NULL) {
 
106
        while(fmap_gets(map, buffer, at, sizeof(buffer) - 1)) {
124
107
                unsigned char data[1024];
125
108
                const unsigned char *uptr;
126
109
                size_t len;