(list_copy): Do nothing if src is NULL.
(imap_list): Use mu_argcv_get instead of strtok_r to parse last two tokens of the reply, so that file names containing white space are processed.
Showing
1 changed file
with
24 additions
and
13 deletions
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2003, 2004, | 2 | Copyright (C) 1999, 2000, 2001, 2003, 2004, |
3 | 2005 Free Software Foundation, Inc. | 3 | 2005, 2006 Free Software Foundation, Inc. |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public |
... | @@ -830,6 +830,9 @@ list_copy (mu_list_t dst, mu_list_t src, | ... | @@ -830,6 +830,9 @@ list_copy (mu_list_t dst, mu_list_t src, |
830 | { | 830 | { |
831 | mu_iterator_t itr; | 831 | mu_iterator_t itr; |
832 | 832 | ||
833 | if (!src) | ||
834 | return; | ||
835 | |||
833 | mu_list_get_iterator (src, &itr); | 836 | mu_list_get_iterator (src, &itr); |
834 | for (mu_iterator_first (itr); !mu_iterator_is_done (itr); | 837 | for (mu_iterator_first (itr); !mu_iterator_is_done (itr); |
835 | mu_iterator_next (itr)) | 838 | mu_iterator_next (itr)) |
... | @@ -1325,7 +1328,9 @@ imap_list (f_imap_t f_imap) | ... | @@ -1325,7 +1328,9 @@ imap_list (f_imap_t f_imap) |
1325 | char *buffer; | 1328 | char *buffer; |
1326 | struct mu_list_response *lr; | 1329 | struct mu_list_response *lr; |
1327 | int status = 0; | 1330 | int status = 0; |
1328 | 1331 | int argc; | |
1332 | char **argv; | ||
1333 | |||
1329 | buffer = alloca (len); | 1334 | buffer = alloca (len); |
1330 | memcpy (buffer, f_imap->buffer, len); | 1335 | memcpy (buffer, f_imap->buffer, len); |
1331 | buffer[len] = '\0'; | 1336 | buffer[len] = '\0'; |
... | @@ -1347,7 +1352,7 @@ imap_list (f_imap_t f_imap) | ... | @@ -1347,7 +1352,7 @@ imap_list (f_imap_t f_imap) |
1347 | tok = strtok_r (NULL, " ", &sp); | 1352 | tok = strtok_r (NULL, " ", &sp); |
1348 | /* Get the attibutes. */ | 1353 | /* Get the attibutes. */ |
1349 | tok = strtok_r (NULL, ")", &sp); | 1354 | tok = strtok_r (NULL, ")", &sp); |
1350 | if (tok) | 1355 | if (tok) |
1351 | { | 1356 | { |
1352 | char *s = NULL; | 1357 | char *s = NULL; |
1353 | char *p = tok; | 1358 | char *p = tok; |
... | @@ -1365,15 +1370,19 @@ imap_list (f_imap_t f_imap) | ... | @@ -1365,15 +1370,19 @@ imap_list (f_imap_t f_imap) |
1365 | p = NULL; | 1370 | p = NULL; |
1366 | } | 1371 | } |
1367 | } | 1372 | } |
1368 | /* Hiearchy delimeter. */ | 1373 | |
1369 | tok = strtok_r (NULL, " ", &sp); | 1374 | status = mu_argcv_get (sp, "", NULL, &argc, &argv); |
1370 | if (tok && strlen (tok) > 2 && strcasecmp (tok, "NIL")) | 1375 | if (status == 0) |
1371 | lr->separator = tok[1]; | ||
1372 | /* The path. */ | ||
1373 | tok = strtok_r (NULL, " ", &sp); | ||
1374 | if (tok) | ||
1375 | { | 1376 | { |
1376 | char *s = strchr (tok, '{'); | 1377 | char *s; |
1378 | |||
1379 | /* Hiearchy delimeter. */ | ||
1380 | tok = argv[0]; | ||
1381 | if (tok && tok[1] == 0 && strcasecmp (tok, "NIL")) | ||
1382 | lr->separator = tok[0]; | ||
1383 | /* The path. */ | ||
1384 | tok = argv[1]; | ||
1385 | s = strchr (tok, '{'); | ||
1377 | if (s) | 1386 | if (s) |
1378 | { | 1387 | { |
1379 | size_t n = strtoul (s + 1, NULL, 10); | 1388 | size_t n = strtoul (s + 1, NULL, 10); |
... | @@ -1390,11 +1399,11 @@ imap_list (f_imap_t f_imap) | ... | @@ -1390,11 +1399,11 @@ imap_list (f_imap_t f_imap) |
1390 | else if ((status = imap_string (f_imap, &tok)) == 0) | 1399 | else if ((status = imap_string (f_imap, &tok)) == 0) |
1391 | { | 1400 | { |
1392 | mu_off_t sz = 0; | 1401 | mu_off_t sz = 0; |
1393 | 1402 | ||
1394 | mu_stream_size (f_imap->string.stream, &sz); | 1403 | mu_stream_size (f_imap->string.stream, &sz); |
1395 | lr->name = calloc (sz + 1, 1); | 1404 | lr->name = calloc (sz + 1, 1); |
1396 | if (!lr->name) | 1405 | if (!lr->name) |
1397 | status = ENOMEM; | 1406 | status = ENOMEM; |
1398 | else | 1407 | else |
1399 | mu_stream_read (f_imap->string.stream, lr->name, sz, 0, NULL); | 1408 | mu_stream_read (f_imap->string.stream, lr->name, sz, 0, NULL); |
1400 | mu_stream_truncate (f_imap->string.stream, 0); | 1409 | mu_stream_truncate (f_imap->string.stream, 0); |
... | @@ -1408,6 +1417,8 @@ imap_list (f_imap_t f_imap) | ... | @@ -1408,6 +1417,8 @@ imap_list (f_imap_t f_imap) |
1408 | status = ENOMEM; | 1417 | status = ENOMEM; |
1409 | } | 1418 | } |
1410 | } | 1419 | } |
1420 | mu_argcv_free (argc, argv); | ||
1421 | |||
1411 | return status; | 1422 | return status; |
1412 | } | 1423 | } |
1413 | 1424 | ... | ... |
-
Please register or sign in to post a comment