Skip to content

Commit 9eb94c3

Browse files
committed
HAL: Do not limit HAL command argument length unnecessarily.
The length of any single token in HAL is limited to LINELEN (255 chars) even though line continuation support means that individual commands can be up to MAX_EXTEND_LINES (20) times this length. This patch increments the buffer size by LINELEN until there is plenty of space (to allow for tilde expansion) Fixes #3098
1 parent 7841748 commit 9eb94c3

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

docs/src/man/man1/mqtt-publisher.1.adoc

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,24 +100,21 @@ loadusr -W mqtt-publisher \
100100
halui.axis.c.pos-feedback,halui.axis.u.pos-feedback,\
101101
halui.axis.v.pos-feedback,halui.axis.w.pos-feedback,\
102102
halui.axis.x.pos-feedback,halui.axis.y.pos-feedback,\
103-
halui.axis.z.pos-feedback \
104-
keys=halui.estop.is-activated, halui.joint.0.is-homed,\
105-
halui.joint.1.is-homed,halui.joint.2.is-homed,halui.joint.3.is-homed,\
106-
halui.joint.4.is-homed,halui.joint.5.is-homed,halui.joint.6.is-homed,\
107-
halui.joint.7.is-homed,halui.joint.8.is-homed \
108-
keys=halui.machine.is-on,halui.max-velocity.value,halui.mode.is-auto,
109-
halui.mode.is-manual,halui.mode.is-mdi,halui.mode.is-teleop,
103+
halui.axis.z.pos-feedback,halui.estop.is-activated,\
104+
halui.joint.0.is-homed,halui.joint.1.is-homed,halui.joint.2.is-homed,\
105+
halui.joint.3.is-homed,halui.joint.4.is-homed,halui.joint.5.is-homed,\
106+
halui.joint.6.is-homed,halui.joint.7.is-homed,halui.joint.8.is-homed,\
107+
halui.machine.is-on,halui.max-velocity.value,halui.mode.is-auto,\
108+
halui.mode.is-manual,halui.mode.is-mdi,halui.mode.is-teleop,\
110109
halui.program.is-running
110+
111111
----
112112

113113
Note: It is recommended to use the line continuation character "\" as
114114
shown here to improve readability. But note that spaces must be left in
115115
to delimit options, and must not be included (including at the beginning
116116
of a line) inside a single option.
117117

118-
HAL limits a single option/token (for example "keys=") to 255 characters.
119-
To work around this issue use multiple "keys=" entries as shown.
120-
121118
== SEE ALSO
122119

123120
hal(3hal)

src/hal/utils/halcmd.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,12 @@ static int parse_cmd1(char **argv) {
362362
int i;
363363
for(i=0; i<argc; i++)
364364
{
365-
char *buf = malloc(LINELEN);
366-
TildeExpansion(argv[i], buf, LINELEN);
365+
size_t len = LINELEN;
366+
// Tilde expansion can make the string longer, so ensure
367+
// there is space for that
368+
while (len < strlen(argv[i]) * 2) len += LINELEN;
369+
char *buf = malloc(len);
370+
TildeExpansion(argv[i], buf, len);
367371
argv[i] = buf;
368372
}
369373
}

0 commit comments

Comments
 (0)