[imapfilter-devel] Searches only return first matching result? (v2.2.2)
Lefteris Chatzimparmpas
lefcha at hellug.gr
Sat Jan 15 18:44:01 EET 2011
Hello,
Great work! You found the bug! :-)
You're right, that line (response.c:550) shouldn't be there at all, since
the pointer is incremented for the space in the previous line.
Thanks for reporting this and debugging it, too!
L.
On 01/14/2011 04:50 PM, Jesse Connell wrote:
> Hi again,
>
> Thanks! Here's a resulting debug file, using the config text below.
>
> account = IMAP {
> server = 'localhost',
> port = 1143,
> username = 'jesse08'
> }
> account.INBOX:check_status()
> test = account.INBOX:select_all()
>
> I also tried investigating this a bit myself, and particularly looked at
> the string manipulation in response_search(). It looked to me like when
> the pointer "m" gets incremented by a space's worth (line 550-ish?) it
> skips over the NULL character in the buffer instead of positioning it
> right at that spot. Printing a fixed-size chunk of the messages buffer
> in hex showed a bunch of message numbers separated by both NULL and
> space-- and commenting out that m += strlen(" "); line trims out the
> inner NULLs and actually made it work! (And what really confuses me is
> that this modified version still worked for my GMail account, rather
> than segfaulting or doing something awful.)
>
> I'd give you a concrete example, but I hadn't saved my work from before
> and I can't seem to replicate it (strings and pointers in C are not my
> strong point), and on top of that my Exchange account is apparently
> broken. I'll see if I can get it again when things are working, though.
> Thanks very much for your help on this.
>
> Jesse
>
> On 01/08/2011 12:01 PM, Lefteris Chatzimparmpas wrote:
>> Hello,
>>
>> Can you apply the attached patch against 2.2.2 and reproduce the problem
>> while running with the -d option. For example here are some
>> instructions, without the need to install:
>>
>> $ tar zxf imapfilter-2.2.2.tar.gz
>> $ cd imapfilter-2.2.2
>> $ patch< ~/debug-search.diff
>> $ make SHAREDIR=.
>> $ ./imapfilter -d
>>
>> Thank you!
>>
>>
>> On 12/20/2010 05:45 PM, Jesse Connell wrote:
>>> On 12/20/2010 09:42 AM, Jesse Connell wrote:
>>>> Hi there,
>>>>
>>>> I've compiled and installed imapfilter 2.2.2 and I'm trying to run some
>>>> filters on my Microsoft Exchange account at work through davmail
>>>> gateway
>>>> -- http://davmail.sourceforge.net/ . I'm basically connecting to an
>>>> IMAP
>>>> server running locally, which converts the requests to Microsoft
>>>> moon-speak on the fly and then delivers the results.
>>>>
>>>> Most things work fine, but whenever I try any sort of search function
>>>> (like select_all, contain_subject, etc.) it only seems to return the
>>>> first message it finds that matches the criteria. Here's my testing
>>>> config.lua and the output I actually see:
>>>>
>>>>
>>>> account = IMAP {
>>>> server = 'localhost',
>>>> username = 'jesse08',
>>>> port = 1143
>>>> }
>>>> account.INBOX:check_status()
>>>> test = account.INBOX:select_all()
>>>> print('messages in INBOX:')
>>>> for _, message in ipairs(test) do
>>>> mailbox, uid = unpack(message)
>>>> print(mailbox[uid]:fetch_field('Subject:'))
>>>> end
>>>>
>>>>
>>>> Enter password for jesse08 at localhost:
>>>> 235 messages, 235 recent, 0 unseen, in jesse08 at localhost/INBOX.
>>>> messages in INBOX:
>>>> Subject: Tuition Exchange Program Notification for 2011-2012
>>>>
>>>>
>>>> I can't quite tell if it's imapfilter, davmail, or my own inexperience
>>>> with lua that's to blame. In davmail's defense, its running log shows
>>>> all messages in the INBOX being listed, and then a request for the
>>>> subject field of that single message. Any ideas? Thanks,
>>>>
>>>> Jesse
>>>
>>> And if I'd taken another look at the man page, I'd have thought to
>>> provide the debug log in the first place! Here it is.
>>>
>>> Jesse
>>>
>>>
>>> getting response (4):
>>>
>>> * OK [CAPABILITY IMAP4REV1 AUTH=LOGIN] IMAP4rev1 DavMail 3.8.7-1558
>>> server ready
>>>
>>> sending command (4):
>>>
>>> 1000 NOOP
>>>
>>> getting response (4):
>>>
>>> 1000 BAD command authentication required
>>>
>>> sending command (4):
>>>
>>> 1001 CAPABILITY
>>>
>>> getting response (4):
>>>
>>> * CAPABILITY IMAP4REV1 AUTH=LOGIN
>>>
>>> getting response (4):
>>>
>>> 1001 OK CAPABILITY completed
>>>
>>> sending command (4):
>>>
>>> 1002 LOGIN "jesse08" *
>>>
>>> getting response (4):
>>>
>>> 1002 OK Authenticated
>>>
>>> sending command (4):
>>>
>>> 1003 STATUS "INBOX" (MESSAGES RECENT UNSEEN)
>>>
>>> getting response (4):
>>>
>>> * STATUS "INBOX" (MESSAGES 256 RECENT 256 UNSEEN 0)
>>>
>>> getting response (4):
>>>
>>> 1003 OK STATUS completed
>>>
>>> sending command (4):
>>>
>>> 1004 SELECT "INBOX"
>>>
>>> getting response (4):
>>>
>>> * 256 EXISTS
>>>
>>> getting response (4):
>>>
>>> * 256 RECENT
>>> * OK [UIDVALIDITY 1]
>>> * OK [UIDNEXT 17579]
>>> * FLAGS (\Answered \Deleted \Draft \Flagged \Seen $Forwarded Junk)
>>> * OK [PERMANENTFLAGS (\Answered \Deleted \Draft \Flagged \Seen
>>> $Forwarded Junk)]
>>> 1004 OK [READ-WRITE] SELECT completed
>>>
>>> sending command (4):
>>>
>>> 1005 UID SEARCH ALL
>>>
>>> getting response (4):
>>>
>>> * SEARCH 9248
>>>
>>> getting response (4):
>>>
>>> * SEARCH 12901
>>> * SEARCH 13258
>>> * SEARCH 14549
>>> * SEARCH 16121
>>> * SEARCH 16174
>>> * SEARCH 16275
>>> * SEARCH 16535
>>> * SEARCH 16537
>>> * SEARCH 16602
>>> * SEARCH 16778
>>> * SEARCH 16843
>>> * SEARCH 16964
>>> * SEARCH 16982
>>> * SEARCH 16984
>>> * SEARCH 17003
>>> * SEARCH 17008
>>> * SEARCH 17030
>>> * SEARCH 17105
>>> * SEARCH 17106
>>> * SEARCH 17107
>>> * SEARCH 17115
>>> * SEARCH 17145
>>> * SEARCH 17157
>>> * SEARCH 17163
>>> * SEARCH 17175
>>> * SEARCH 17176
>>> * SEARCH 17191
>>> * SEARCH 17214
>>> * SEARCH 17217
>>> * SEARCH 17218
>>> * SEARCH 17219
>>> * SEARCH 17220
>>> * SEARCH 17221
>>> * SEARCH 17226
>>> * SEARCH 17229
>>> * SEARCH 17230
>>> * SEARCH 17231
>>> * SEARCH 17232
>>> * SEARCH 17233
>>> * SEARCH 17234
>>> * SEARCH 17235
>>> * SEARCH 17236
>>> * SEARCH 17248
>>> * SEARCH 17249
>>> * SEARCH 17251
>>> * SEARCH 17252
>>> * SEARCH 17253
>>> * SEARCH 17254
>>> * SEARCH 17255
>>> * SEARCH 17256
>>> * SEARCH 17258
>>> * SEARCH 17259
>>> * SEARCH 17260
>>> * SEARCH 17261
>>> * SEARCH 17262
>>> * SEARCH 17263
>>> * SEARCH 17264
>>> * SEARCH 17265
>>> * SEARCH 17266
>>> * SEARCH 17267
>>> * SEARCH 17268
>>> * SEARCH 17269
>>> * SEARCH 17270
>>> * SEARCH 17271
>>> * SEARCH 17272
>>> * SEARCH 17273
>>> * SEARCH 17274
>>> * SEARCH 17275
>>> * SEARCH 17276
>>> * SEARCH 17277
>>> * SEARCH 17278
>>> * SEARCH 17279
>>> * SEARCH 17280
>>> * SEARCH 17281
>>> * SEARCH 17282
>>> * SEARCH 17283
>>> * SEARCH 17284
>>> * SEARCH 17285
>>> * SEARCH 17286
>>> * SEARCH 17287
>>> * SEARCH 17288
>>> * SEARCH 17289
>>> * SEARCH 17290
>>> * SEARCH 17291
>>> * SEARCH 17292
>>> * SEARCH 17293
>>> * SEARCH 17294
>>> * SEARCH 17295
>>> * SEARCH 17299
>>> * SEARCH 17303
>>> * SEARCH 17304
>>> * SEARCH 17305
>>> * SEARCH 17306
>>> * SEARCH 17307
>>> * SEARCH 17308
>>> * SEARCH 17309
>>> * SEARCH 17310
>>> * SEARCH 17311
>>> * SEARCH 17312
>>> * SEARCH 17313
>>> * SEARCH 17314
>>> * SEARCH 17315
>>> * SEARCH 17316
>>> * SEARCH 17317
>>> * SEARCH 17318
>>> * SEARCH 17319
>>> * SEARCH 17320
>>> * SEARCH 17321
>>> * SEARCH 17322
>>> * SEARCH 17323
>>> * SEARCH 17332
>>> * SEARCH 17333
>>> * SEARCH 17334
>>> * SEARCH 17335
>>> * SEARCH 17336
>>> * SEARCH 17337
>>> * SEARCH 17338
>>> * SEARCH 17339
>>> * SEARCH 17340
>>> * SEARCH 17341
>>> * SEARCH 17342
>>> * SEARCH 17343
>>> * SEARCH 17344
>>> * SEARCH 17345
>>> * SEARCH 17346
>>> * SEARCH 17347
>>> * SEARCH 17348
>>> * SEARCH 17349
>>> * SEARCH 17350
>>> * SEARCH 17351
>>> * SEARCH 17352
>>> * SEARCH 17353
>>> * SEARCH 17354
>>> * SEARCH 17355
>>> * SEARCH 17356
>>> * SEARCH 17357
>>> * SEARCH 17358
>>> * SEARCH 17359
>>> * SEARCH 17360
>>> * SEARCH 17361
>>> * SEARCH 17362
>>> * SEARCH 17363
>>> * SEARCH 17364
>>> * SEARCH 17365
>>> * SEARCH 17366
>>> * SEARCH 17367
>>> * SEARCH 17368
>>> * SEARCH 17369
>>> * SEARCH 17370
>>> * SEARCH 17371
>>> * SEARCH 17372
>>> * SEARCH 17373
>>> * SEARCH 17374
>>> * SEARCH 17375
>>> * SEARCH 17376
>>> * SEARCH 17377
>>> * SEARCH 17378
>>> * SEARCH 17379
>>> * SEARCH 17380
>>> * SEARCH 17381
>>> * SEARCH 17382
>>> * SEARCH 17383
>>> * SEARCH 17384
>>> * SEARCH 17385
>>> * SEARCH 17386
>>> * SEARCH 17387
>>> * SEARCH 17388
>>> * SEARCH 17389
>>> * SEARCH 17390
>>> * SEARCH 17391
>>> * SEARCH 17392
>>> * SEARCH 17393
>>> * SEARCH 17394
>>> * SEARCH 17395
>>> * SEARCH 17396
>>> * SEARCH 17397
>>> * SEARCH 17400
>>> * SEARCH 17401
>>> * SEARCH 17402
>>> * SEARCH 17403
>>> * SEARCH 17404
>>> * SEARCH 17405
>>> * SEARCH 17406
>>> * SEARCH 17409
>>> * SEARCH 17425
>>> * SEARCH 17429
>>> * SEARCH 17430
>>> * SEARCH 17431
>>> * SEARCH 17432
>>> * SEARCH 17433
>>> * SEARCH 17434
>>> * SEARCH 17435
>>> * SEARCH 17436
>>> * SEARCH 17437
>>> * SEARCH 17438
>>> * SEARCH 17439
>>> * SEARCH 17440
>>> * SEARCH 17441
>>> * SEARCH 17444
>>> * SEARCH 17445
>>> * SEARCH 17446
>>> * SEARCH 17449
>>> * SEARCH 17450
>>> * SEARCH 17451
>>> * SEARCH 17452
>>> * SEARCH 17453
>>> * SEARCH 17454
>>> * SEARCH 17455
>>> * SEARCH 17456
>>> * SEARCH 17457
>>> * SEARCH 17458
>>> * SEARCH 17461
>>> * SEARCH 17462
>>> * SEARCH 17465
>>> * SEARCH 17466
>>> * SEARCH 17467
>>> * SEARCH 17468
>>> * SEARCH 17483
>>> * SEARCH 17488
>>> * SEARCH 17489
>>> * SEARCH 17490
>>> * SEARCH 17491
>>> * SEARCH 17520
>>> * SEARCH 17521
>>> * SEARCH 17523
>>> * SEARCH 17525
>>> * SEARCH 17532
>>> * SEARCH 17533
>>> * SEARCH 17538
>>> * SEARCH 17551
>>> * SEARCH 17552
>>> * SEARCH 17553
>>> * SEARCH 17556
>>> * SEARCH 17557
>>> * SEARCH 17558
>>> * SEARCH 17559
>>> * SEARCH 17560
>>> * SEARCH 17561
>>> * SEARCH 17562
>>> * SEARCH 17563
>>> * SEARCH 17564
>>> * SEARCH 17565
>>> * SEARCH 17566
>>> * SEARCH 17567
>>> * SEARCH 17568
>>> * SEARCH 17569
>>> * SEARCH 17570
>>> * SEARCH 17571
>>> * SEARCH 17572
>>> * SEARCH 17573
>>> * SEARCH 17574
>>> * SEARCH 17575
>>> * SEARCH 17576
>>> * SEARCH 17577
>>> * SEARCH 17578
>>> 1005 OK SEARCH c
>>> getting response (4):
>>>
>>> ompleted
>>>
>>> sending command (4):
>>>
>>> 1006 UID FETCH 9248 BODY.PEEK[HEADER.FIELDS (Subject:)]
>>>
>>> getting response (4):
>>>
>>> * 1 FETCH (UID 9248 BODY[HEADER.FIELDS (Subject:)] {62}
>>>
>>> getting response (4):
>>>
>>> Subject: Tuition Exchange Program Notification for 2011-2012
>>> )
>>> 1006 OK UID FETCH completed
>>>
>>> sending command (4):
>>>
>>> 1007 LOGOUT
>>>
>>> getting response (4):
>>>
>>> * BYE Closing connection
>>>
>>> _______________________________________________
>>> Imapfilter-devel mailing list
>>> Imapfilter-devel at lists.hellug.gr
>>> http://lists.hellug.gr/mailman/listinfo/imapfilter-devel
>
>
> _______________________________________________
> Imapfilter-devel mailing list
> Imapfilter-devel at lists.hellug.gr
> http://lists.hellug.gr/mailman/listinfo/imapfilter-devel
More information about the Imapfilter-devel
mailing list