# Imap\_client\_buffer not being obeyed

**URL:** <https://www.ruby-forum.com/t/imap-client-buffer-not-being-obeyed/223487>\
**Category:** NGINX\
**Created:** [October 6, 2012, 7:54am UTC](https://www.ruby-forum.com/t/imap-client-buffer-not-being-obeyed/223487 "2012-10-06T07:54:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [October 6, 2012, 7:54am UTC](https://www.ruby-forum.com/t/imap-client-buffer-not-being-obeyed/223487/1 "2012-10-06T07:54:47Z")

</div>

I have imap\_client\_buffer set to 64k(as required by imap protocol) in  
the  
nginx.conf file  
However when an imap client sends a very long command, post  
authentication,  
the length gets truncated at 4k(the default page size of the linux  
operating  
system)

how can i debug this problem? i have stepped through the code using gdb.  
as  
far as i can see, in mail\_proxy module, the value of the conf  
file(120000  
for testing) was correctly seen

gdb) p p-\>upstream.connection-\>data  
$24 = (void \*) 0x9e4bd48  
(gdb) p s  
$25 = (ngx\_mail\_session\_t \*) 0x9e4bd48  
(gdb) p p-\>buffer-\>end  
Cannot access memory at address 0x1c  
(gdb) p s-\>buffer-\>end - s-\>buffer-\>last  
$26 = 120000  
(gdb) p s  
$27 = (ngx\_mail\_session\_t \*) 0x9e4bd48  
(gdb) n  
205 pcf = ngx\_mail\_get\_module\_srv\_conf(s,  
ngx\_mail\_proxy\_module);  
(gdb) n  
207 s-\>proxy-\>buffer = ngx\_create\_temp\_buf(s-\>connection-\>pool,  
(gdb) p pcf  
$28 = (ngx\_mail\_proxy\_conf\_t \*) 0x9e3c480  
(gdb) p \*pcf  
$29 = {enable = 1, pass\_error\_message = 1, xclient = 1, buffer\_size =  
120000,  
timeout = 86400000, upstream\_quick\_retries = 0, upstream\_retries = 0,  
min\_initial\_retry\_delay = 3000, max\_initial\_retry\_delay = 3000,  
max\_retry\_delay = 60000}

When the command below is sent using telnet, only 4 k of data is  
accepted,  
then nginx hangs until i hit enter on keyboard…after which the  
truncated command is sent to the upstream imap server.

I am using nginx 0.78, is this a known issue?

This is the command sent

HP1L UID FETCH  
344990,344996,344998,345004,345006,345010:345011,345015,345020,345043,345046,345049:345050,345053,345057:345059,345071,345080,345083,345085,345090,345092:345093,345096,345101:345102,345106,345112,345117,345136,345140,345142:345144,345146:345147,345150,345161,345163,345167,345174:345176,345195,345197,345203,345205,345207:345209,345214,345218,345221,345224,345229,345231,345233,345236,345239,345248,345264,345267,345272,345285,345290,345292,345301,345305,345308,345316,345320,345322,345324,345327,345358,345375,345384,345386,345391,345409,345427:345428,345430:345432,345434:345435,345437,345439,345443,345448,345450,345463,345468:345470,345492,345494,345499,345501,345504,345506,345515:345519,345522,345525,345535,345563,345568,345574,345577,345580,345582,345599,345622,345626,345630,345632:345633,345637,345640,345647:345648,345675,345684,345686:345687,345703:345704,345714:345717,345720,345722:345724,345726,345730,345734:345737,345749,345756,345759,345783,345785:345787,345790,345806:345807,3458  
12,345816,345720,345722:345724,345726,345730,345734:345737,345749,345756,345759,345783,345785:345787,345790,345806:345807,345812,345817,345902,345919,345953,345978,345981,345984,345990,345997,346004,346008:346009,346011:346012,346022,346039,346044,346050,346061:346062,346066:346067,346075:346076,346081,346088,346090,346093,346096,346098:346099,346110,346140,346170,346172:346174,346187,346189,346193:346194,346197,346204,346212,346225,346241,346244,346259,346323,346325:346328,346331:346332,346337:346338,346342,346346,346353,346361:346362,346364,346420,346426,346432,346447,346450:346451,346453:346454,346456:346457,346459:346460,346466:346468,346474,346476,346479,346483,346496,346498:346501,346504,346530,346539,346546,346576,346589:346590,346594:346595,346601,346607:346609,346612,346614:346615,346617:346618,346625,346631,346638,346641,346654,346657,346661,346665,346671,346687:346688,346693,346695,346734:346735,346741,346747:346748,346755,346757,346777,346779,346786:346788,346791,346793,  
346801,346815,346821:346822,346825,346828,346837,346839,346843,346848,346857:346858,346860,346862:346863,346866,346868:346869,346877,346883,346895:346897,346899,346923,346927,346945,346948,346961,346964:346966,346968,346970,346974,346987,346989:346990,346992,347000,347003,347008:347011,347013,347021,347028,347032:347034,347036,347049,347051,347058,347076,347079,347081,347083,347085,347092,347096,347108,347130,347145:347148,347150,347155:347158,347161,347163:347164,347181,347184,347187:347189,347204,347210:347211,347215,347217:347220,347227:347228,347234,347244,347246,347251,347253,347263:347264,347266,347268,347275,347292,347294,347304,347308,347317:347320,347322,347325:347327,347340:347341,347346,347352:347353,347357,347360:347361,347375,347379,347382:347386,347389,347392,347402,347405:347406,347411,347433:347434,347438,347440:347441,347443:347444,347448,347459:347460,347465,347468:347469,347476:347479,347490,347497,347506,347526,347530,347545,347547,347555:347556,347601:347605,347  
632,347634,347641,347643:347646,347649,347653,347660,347668,347676,347707,347719,347722,347724,347727:347732,347735,347746,347754,347756:347757,347761,347776,347779,347791,347798,347800,347805,347816:347817,347822,347837,347841,347843,347846,347848,347851,347879,347885,347892:347894,347903,347907:347911,347915:347916,347918,347950,347952:347953,347981,347986:347988,348001,348037:348038,348049,348052,348056:348058,348061,348072,348074,348077:348078,348080,348082,348100,348105,348109,348111:348116,348119:348123,348131:348132,348138,348150:348151,348153,348157,348161:348163,348166,348168:348169,348171,348173,348176,348178,348180:348181,348201,348204,348208,348218:348219,348222,348226,348229:348230,348235,348238:348240,348244:348247,348249,348251:348253,348256:348257,348263,348285,348288:348289,348293,348298:348299,348301:348302,348305:348306,348310,348327,348332:348337,348340,348342,348344,348348,348351:348353,348356:348357,348360,348366,348377,348386,348390,348398,348400:348401,348406  
:348407,348419,348422,348424,348427:348428,348430,348432:348433,348439,348444,348447:348448,348450:348451,348454,348456,348459:348460,348473,348493,348497:348498,348504,348506,348508,348516,348520,348527,348530,348532,348546:348547,348551,348560:348563,348567,348570:348572,348574,348577,348581,348588,348595,348610,348632,348636,348642,348646,348667,348672:348673,348679,348703,348713:348714,348716,348718:348722,348728:348729,348731,348735,348743:348745,348749,348751:348752,348759,348768,348773,348780:348781,348784:348791  
(UID FLAGS)

Posted at Nginx Forum:

> **[imap\_client\_buffer not being obeyed](https://forum.nginx.org/read.php?2,231439,231439#msg-231439)**
>
> I have imap\_client\_buffer set to 64k(as required by imap protocol) in the nginx.conf file However when an imap client sends a very long command, post authentication, the length gets truncated at 4k(the default page size of the linux operating system)...

---

<div class="post-metadata">

**Author:** ![iceman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/46a35a/32.png) [@iceman](https://www.ruby-forum.com/u/iceman)\
**Post date:** [October 6, 2012, 7:55am UTC](https://www.ruby-forum.com/t/imap-client-buffer-not-being-obeyed/223487/2 "2012-10-06T07:55:58Z")

</div>

```
HP1L UID FETCH
344990,344996,344998,345004,345006,345010:345011,345015,345020,345043,345046,345049:345050,345053,345057:345059,345071,345080,345083,345085,345090,345092:345093,345096,345101:345102,345106,345112,345117,345136,345140,345142:345144,345146:345147,345150,345161,345163,345167,345174:345176,345195,345197,345203,345205,345207:345209,345214,345218,345221,345224,345229,345231,345233,345236,345239,345248,345264,345267,345272,345285,345290,345292,345301,345305,345308,345316,345320,345322,345324,345327,345358,345375,345384,345386,345391,345409,345427:345428,345430:345432,345434:345435,345437,345439,345443,345448,345450,345463,345468:345470,345492,345494,345499,345501,345504,345506,345515:345519,345522,345525,345535,345563,345568,345574,345577,345580,345582,345599,345622,345626,345630,345632:345633,345637,345640,345647:345648,345675,345684,345686:345687,345703:345704,345714:345717,345720,345722:345724,345726,345730,345734:345737,345749,345756,345759,345783,345785:345787,345790,345806:345807,3458
 12,345816,345720,345722:345724,345726,345730,345734:345737,345749,345756,345759,345783,345785:345787,345790,345806:345807,345812,345817,345902,345919,345953,345978,345981,345984,345990,345997,346004,346008:346009,346011:346012,346022,346039,346044,346050,346061:346062,346066:346067,346075:346076,346081,346088,346090,346093,346096,346098:346099,346110,346140,346170,346172:346174,346187,346189,346193:346194,346197,346204,346212,346225,346241,346244,346259,346323,346325:346328,346331:346332,346337:346338,346342,346346,346353,346361:346362,346364,346420,346426,346432,346447,346450:346451,346453:346454,346456:346457,346459:346460,346466:346468,346474,346476,346479,346483,346496,346498:346501,346504,346530,346539,346546,346576,346589:346590,346594:346595,346601,346607:346609,346612,346614:346615,346617:346618,346625,346631,346638,346641,346654,346657,346661,346665,346671,346687:346688,346693,346695,346734:346735,346741,346747:346748,346755,346757,346777,346779,346786:346788,346791,346793,
 346801,346815,346821:346822,346825,346828,346837,346839,346843,346848,346857:346858,346860,346862:346863,346866,346868:346869,346877,346883,346895:346897,346899,346923,346927,346945,346948,346961,346964:346966,346968,346970,346974,346987,346989:346990,346992,347000,347003,347008:347011,347013,347021,347028,347032:347034,347036,347049,347051,347058,347076,347079,347081,347083,347085,347092,347096,347108,347130,347145:347148,347150,347155:347158,347161,347163:347164,347181,347184,347187:347189,347204,347210:347211,347215,347217:347220,347227:347228,347234,347244,347246,347251,347253,347263:347264,347266,347268,347275,347292,347294,347304,347308,347317:347320,347322,347325:347327,347340:347341,347346,347352:347353,347357,347360:347361,347375,347379,347382:347386,347389,347392,347402,347405:347406,347411,347433:347434,347438,347440:347441,347443:347444,347448,347459:347460,347465,347468:347469,347476:347479,347490,347497,347506,347526,347530,347545,347547,347555:347556,347601:347605,347
 632,347634,347641,347643:347646,347649,347653,347660,347668,347676,347707,347719,347722,347724,347727:347732,347735,347746,347754,347756:347757,347761,347776,347779,347791,347798,347800,347805,347816:347817,347822,347837,347841,347843,347846,347848,347851,347879,347885,347892:347894,347903,347907:347911,347915:347916,347918,347950,347952:347953,347981,347986:347988,348001,348037:348038,348049,348052,348056:348058,348061,348072,348074,348077:348078,348080,348082,348100,348105,348109,348111:348116,348119:348123,348131:348132,348138,348150:348151,348153,348157,348161:348163,348166,348168:348169,348171,348173,348176,348178,348180:348181,348201,348204,348208,348218:348219,348222,348226,348229:348230,348235,348238:348240,348244:348247,348249,348251:348253,348256:348257,348263,348285,348288:348289,348293,348298:348299,348301:348302,348305:348306,348310,348327,348332:348337,348340,348342,348344,348348,348351:348353,348356:348357,348360,348366,348377,348386,348390,348398,348400:348401,348406
 :348407,348419,348422,348424,348427:348428,348430,348432:348433,348439,348444,348447:348448,348450:348451,348454,348456,348459:348460,348473,348493,348497:348498,348504,348506,348508,348516,348520,348527,348530,348532,348546:348547,348551,348560:348563,348567,348570:348572,348574,348577,348581,348588,348595,348610,348632,348636,348642,348646,348667,348672:348673,348679,348703,348713:348714,348716,348718:348722,348728:348729,348731,348735,348743:348745,348749,348751:348752,348759,348768,348773,348780:348781,348784:348791
(UID FLAGS)
```

Posted at Nginx Forum:

> **[Re: imap\_client\_buffer not being obeyed](https://forum.nginx.org/read.php?2,231439,231440#msg-231440)**
>
> I have imap\_client\_buffer set to 64k(as required by imap protocol) in the nginx.conf file However when an imap client sends a very long command, post authentication, the length gets truncated at 4k(the default page size of the linux operating system)...

---

<div class="post-metadata">

**Author:** ![iceman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/46a35a/32.png) [@iceman](https://www.ruby-forum.com/u/iceman)\
**Post date:** [October 6, 2012, 7:57am UTC](https://www.ruby-forum.com/t/imap-client-buffer-not-being-obeyed/223487/3 "2012-10-06T07:57:43Z")

</div>

the entire command does not show up on the webpage, copy and paste the  
snippet in an editor

Posted at Nginx Forum:

> **[Re: imap\_client\_buffer not being obeyed](https://forum.nginx.org/read.php?2,231439,231441#msg-231441)**
>
> I have imap\_client\_buffer set to 64k(as required by imap protocol) in the nginx.conf file However when an imap client sends a very long command, post authentication, the length gets truncated at 4k(the default page size of the linux operating system)...

---

<div class="post-metadata">

**Author:** ![iceman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/46a35a/32.png) [@iceman](https://www.ruby-forum.com/u/iceman)\
**Post date:** [October 8, 2012, 7:42am UTC](https://www.ruby-forum.com/t/imap-client-buffer-not-being-obeyed/223487/4 "2012-10-08T07:42:15Z")

</div>

guys, any ideas?

Posted at Nginx Forum:

> **[Re: imap\_client\_buffer not being obeyed](https://forum.nginx.org/read.php?2,231439,231463#msg-231463)**
>
> I have imap\_client\_buffer set to 64k(as required by imap protocol) in the nginx.conf file However when an imap client sends a very long command, post authentication, the length gets truncated at 4k(the default page size of the linux operating system)...

---

<div class="post-metadata">

**Author:** ![iceman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/46a35a/32.png) [@iceman](https://www.ruby-forum.com/u/iceman)\
**Post date:** [October 8, 2012, 12:58pm UTC](https://www.ruby-forum.com/t/imap-client-buffer-not-being-obeyed/223487/5 "2012-10-08T12:58:15Z")

</div>

Hello!

On Sat, Oct 06, 2012 at 01:53:54AM -0400, iceman wrote:

> gdb) p p-\>upstream.connection-\>data  
> 205 pcf = ngx\_mail\_get\_module\_srv\_conf(s, ngx\_mail\_proxy\_module);
> 
> When the command below is sent using telnet, only 4 k of data is accepted,  
> then nginx hangs until i hit enter on keyboard…after which the  
> truncated command is sent to the upstream imap server.
> 
> I am using nginx 0.78, is this a known issue?

I would recommend the following:

a) Test with something better than telnet. While telnet is  
generally usable for testing, it might have issues with testing  
things buffer sizes as telnet usually have it’s own buffers.  
Moreover, usually telnet works in line-at-a-time mode, which means  
it’s telnet who is responsible for handling of the command until  
you hit enter.

b) If you still see the issue, upgrade to at least latest stable  
version of nginx, 1.2.4, before further testing. There is no such  
version “0.78”, but as long as it starts with “0.” it’s really  
old.

–  
Maxim D.

> **[F5 NGINX: Built for cloud-native apps. Ready for AI traffic.](https://www.f5.com/products/nginx)**
>
> Deliver modern applications with NGINX. Explore high-performance load balancing, API gateways, and web server solutions trusted by top global enterprises.
