Revision 3194 libsylph/pop.c

View differences:

pop.c
116 116
{
117 117
	if (session_start_tls(SESSION(session)) < 0) {
118 118
		session->error_val = PS_SOCKET;
119
		return -1;
119
		return PS_SOCKET;
120 120
	}
121 121
	return PS_SUCCESS;
122 122
}
......
156 156
		log_warning(_("Required APOP timestamp not found "
157 157
			      "in greeting\n"));
158 158
		session->error_val = PS_PROTOCOL;
159
		return -1;
159
		return PS_PROTOCOL;
160 160
	}
161 161

  
162 162
	if ((end = strchr(start, '>')) == NULL || end == start + 1) {
163 163
		log_warning(_("Timestamp syntax error in greeting\n"));
164 164
		session->error_val = PS_PROTOCOL;
165
		return -1;
165
		return PS_PROTOCOL;
166 166
	}
167 167

  
168 168
	*(end + 1) = '\0';
......
170 170
	if (!is_ascii_str(start) || strchr(start, '@') == NULL) {
171 171
		log_warning(_("Invalid timestamp in greeting\n"));
172 172
		session->error_val = PS_PROTOCOL;
173
		return -1;
173
		return PS_PROTOCOL;
174 174
	}
175 175

  
176 176
	apop_str = g_strconcat(start, session->pass, NULL);
......
198 198
	if (sscanf(msg, "%d %lld", &session->count, &session->total_bytes) != 2) {
199 199
		log_warning(_("POP3 protocol error\n"));
200 200
		session->error_val = PS_PROTOCOL;
201
		return -1;
201
		return PS_PROTOCOL;
202 202
	} else {
203 203
		if (session->count == 0) {
204 204
			session->uidl_is_valid = TRUE;
......
225 225
	if (sscanf(msg, "%d", &last) == 0) {
226 226
		log_warning(_("POP3 protocol error\n"));
227 227
		session->error_val = PS_PROTOCOL;
228
		return -1;
228
		return PS_PROTOCOL;
229 229
	} else {
230 230
		if (session->count > last) {
231 231
			session->new_msg_exist = TRUE;
......
257 257

  
258 258
	while (p < lastp) {
259 259
		if ((newline = memchr(p, '\r', lastp - p)) == NULL)
260
			return -1;
260
			return PS_PROTOCOL;
261 261
		buf_len = MIN(newline - p, sizeof(buf) - 1);
262 262
		memcpy(buf, p, buf_len);
263 263
		buf[buf_len] = '\0';
......
309 309

  
310 310
	while (p < lastp) {
311 311
		if ((newline = memchr(p, '\r', lastp - p)) == NULL)
312
			return -1;
312
			return PS_PROTOCOL;
313 313
		buf_len = MIN(newline - p, sizeof(buf) - 1);
314 314
		memcpy(buf, p, buf_len);
315 315
		buf[buf_len] = '\0';
......
319 319

  
320 320
		if (sscanf(buf, "%u %u", &num, &size) != 2) {
321 321
			session->error_val = PS_PROTOCOL;
322
			return -1;
322
			return PS_PROTOCOL;
323 323
		}
324 324

  
325 325
		if (num > 0 && num <= session->count)
......
347 347
	if (pop3_write_msg_to_file(file, fp, len) < 0) {
348 348
		g_free(file);
349 349
		session->error_val = PS_IOERR;
350
		return -1;
350
		return PS_IOERR;
351 351
	}
352 352

  
353 353
	drop_ok = session->drop_message(session, file);
......
355 355
	g_free(file);
356 356
	if (drop_ok < 0) {
357 357
		session->error_val = PS_IOERR;
358
		return -1;
358
		return PS_IOERR;
359 359
	}
360 360

  
361 361
	session->cur_total_bytes += session->msg[session->cur_msg].size;
......
723 723
	} else
724 724
		ok = PS_PROTOCOL;
725 725

  
726
	session->error_val = ok;
726
	/* don't overwrite previous error on logout */
727
	if (session->state != POP3_LOGOUT)
728
		session->error_val = ok;
729

  
727 730
	return ok;
728 731
}
729 732

  
......
738 741
	    pop3_session->state != POP3_GETSIZE_LIST_RECV) {
739 742
		val = pop3_ok(pop3_session, msg);
740 743
		if (val != PS_SUCCESS) {
741
			if (val != PS_NOTSUPPORTED) {
744
			if (val == PS_SOCKET) {
742 745
				pop3_session->state = POP3_ERROR;
743 746
				return -1;
744 747
			}
748
			if (val != PS_NOTSUPPORTED) {
749
				if (pop3_session->state != POP3_LOGOUT) {
750
					if (pop3_logout_send(pop3_session) == PS_SUCCESS)
751
						return 0;
752
					else
753
						return -1;
754
				}
755
			}
745 756
		}
746 757

  
747 758
		if (*body == '+' || *body == '-')

Also available in: Unified diff