1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | #include <unistd.h> |
22 | #include <errno(*__errno_location ()).h> |
23 | #include <string.h> |
24 | |
25 | #include <ftpconn.h> |
26 | #include "priv.h" |
27 | |
28 | |
29 | error_t |
30 | ftp_conn_set_type (struct ftp_conn *conn, const char *type) |
31 | { |
32 | error_t err = 0; |
33 | |
34 | if (! type) |
| 1 | Assuming 'type' is non-null | |
|
| |
35 | return EINVAL((0x10 << 26) | ((22) & 0x3fff)); |
36 | |
37 | if (!conn->type || strcmp (type, conn->type) != 0) |
38 | { |
39 | type = strdup (type); |
| |
40 | if (! type) |
| 4 | | Assuming 'type' is non-null | |
|
| |
41 | err = ENOMEM((0x10 << 26) | ((12) & 0x3fff)); |
42 | else |
43 | { |
44 | int reply; |
45 | error_t err = ftp_conn_cmd (conn, "type", type, &reply, 0); |
46 | |
47 | if (!err && reply != REPLY_OK200 && reply != REPLY_CLOSED421) |
| 6 | | Assuming 'err' is not equal to 0 | |
|
48 | err = unexpected_reply (conn, reply, 0, 0); |
49 | |
50 | if (!err || err == EPIPE((0x10 << 26) | ((32) & 0x3fff))) |
| |
51 | { |
52 | if (conn->type) |
53 | free ((char *)conn->type); |
54 | conn->type = type; |
55 | } |
56 | } |
57 | } |
58 | |
59 | return err; |
| 8 | | Memory is never released; potential leak of memory pointed to by 'type' |
|
60 | } |