Merge lp:~brianaker/gearmand/GEARMAN_COMMAND_CAN_DO_TIMEOUT-valgrind into lp:gearmand

Proposed by Brian Aker on 2013-06-15
Status: Merged
Merged at revision: 773
Proposed branch: lp:~brianaker/gearmand/GEARMAN_COMMAND_CAN_DO_TIMEOUT-valgrind
Merge into: lp:gearmand
Diff against target: 24 lines (+11/-2)
1 file modified
libgearman-server/server.cc (+11/-2)
To merge this branch: bzr merge lp:~brianaker/gearmand/GEARMAN_COMMAND_CAN_DO_TIMEOUT-valgrind
Reviewer Review Type Date Requested Status
Tangent Trunk 2013-06-15 Pending
Review via email: mp+169607@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libgearman-server/server.cc'
2--- libgearman-server/server.cc 2013-05-11 23:09:32 +0000
3+++ libgearman-server/server.cc 2013-06-15 08:56:29 +0000
4@@ -530,9 +530,18 @@
5
6 case GEARMAN_COMMAND_CAN_DO_TIMEOUT:
7 {
8+ if (packet->arg_size[1] > GEARMAN_MAXIMUM_INTEGER_DISPLAY_LENGTH)
9+ {
10+ return gearmand_log_gerror(GEARMAN_DEFAULT_LOG_PARAM, GEARMAND_INVALID_PACKET, "GEARMAND_INVALID_PACKET:strtol");
11+ }
12+
13+ char strtol_buffer[GEARMAN_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
14+ memcpy(strtol_buffer, packet->arg[1], packet->arg_size[1]);
15+ strtol_buffer[packet->arg_size[1]]= 0;
16 char *endptr;
17- long timeout= strtol((char *)packet->arg[1], &endptr, 10);
18- if (timeout == LONG_MIN or timeout == LONG_MAX)
19+ errno= 0;
20+ long timeout= strtol(strtol_buffer, &endptr, 10);
21+ if (timeout == LONG_MIN or timeout == LONG_MAX or errno != 0)
22 {
23 return gearmand_log_perror(GEARMAN_DEFAULT_LOG_PARAM, errno, "GEARMAN_COMMAND_CAN_DO_TIMEOUT:strtol");
24 }

Subscribers

People subscribed via source and target branches

to all changes: