Lines 27-32
this program. If not, see <http://www.gnu.org/licenses/>. */
Link Here
|
27 |
|
27 |
|
28 |
#include <string.h> |
28 |
#include <string.h> |
29 |
|
29 |
|
|
|
30 |
#if defined (HAVE_LINUX_BINFMTS_H) && defined (HAVE_SYS_USER_H) |
31 |
#include <sys/user.h> |
32 |
#include <linux/binfmts.h> |
33 |
#endif |
34 |
#ifndef PAGE_SIZE |
35 |
# define PAGE_SIZE (sysconf(_SC_PAGESIZE)) |
36 |
#endif |
37 |
|
30 |
/* Default shell to use. */ |
38 |
/* Default shell to use. */ |
31 |
#ifdef WINDOWS32 |
39 |
#ifdef WINDOWS32 |
32 |
#include <windows.h> |
40 |
#include <windows.h> |
Lines 3067-3072
construct_command_argv_internal (char *line, char **restp, char *shell,
Link Here
|
3067 |
#ifdef WINDOWS32 |
3075 |
#ifdef WINDOWS32 |
3068 |
char *command_ptr = NULL; /* used for batch_mode_shell mode */ |
3076 |
char *command_ptr = NULL; /* used for batch_mode_shell mode */ |
3069 |
#endif |
3077 |
#endif |
|
|
3078 |
char *args_ptr; |
3070 |
|
3079 |
|
3071 |
# ifdef __EMX__ /* is this necessary? */ |
3080 |
# ifdef __EMX__ /* is this necessary? */ |
3072 |
if (!unixy_shell && shellflags) |
3081 |
if (!unixy_shell && shellflags) |
Lines 3232-3239
construct_command_argv_internal (char *line, char **restp, char *shell,
Link Here
|
3232 |
return new_argv; |
3241 |
return new_argv; |
3233 |
} |
3242 |
} |
3234 |
|
3243 |
|
|
|
3244 |
#ifdef MAX_ARG_STRLEN |
3245 |
static char eval_line[] = "eval\\ \\\"set\\ x\\;\\ shift\\;\\ "; |
3246 |
#define ARG_NUMBER_DIGITS 5 |
3247 |
#define EVAL_LEN (sizeof(eval_line)-1 + shell_len + 4 \ |
3248 |
+ (7 + ARG_NUMBER_DIGITS) * 2 * line_len / (MAX_ARG_STRLEN - 2)) |
3249 |
#else |
3250 |
#define EVAL_LEN 0 |
3251 |
#endif |
3252 |
|
3235 |
new_line = xmalloc ((shell_len*2) + 1 + sflags_len + 1 |
3253 |
new_line = xmalloc ((shell_len*2) + 1 + sflags_len + 1 |
3236 |
+ (line_len*2) + 1); |
3254 |
+ (line_len*2) + 1 + EVAL_LEN); |
3237 |
ap = new_line; |
3255 |
ap = new_line; |
3238 |
/* Copy SHELL, escaping any characters special to the shell. If |
3256 |
/* Copy SHELL, escaping any characters special to the shell. If |
3239 |
we don't escape them, construct_command_argv_internal will |
3257 |
we don't escape them, construct_command_argv_internal will |
Lines 3253-3258
construct_command_argv_internal (char *line, char **restp, char *shell,
Link Here
|
3253 |
#ifdef WINDOWS32 |
3271 |
#ifdef WINDOWS32 |
3254 |
command_ptr = ap; |
3272 |
command_ptr = ap; |
3255 |
#endif |
3273 |
#endif |
|
|
3274 |
|
3275 |
#if !defined (WINDOWS32) && defined (MAX_ARG_STRLEN) |
3276 |
if (unixy_shell && line_len > MAX_ARG_STRLEN) |
3277 |
{ |
3278 |
unsigned j; |
3279 |
memcpy (ap, eval_line, sizeof (eval_line) - 1); |
3280 |
ap += sizeof (eval_line) - 1; |
3281 |
for (j = 1; j <= 2 * line_len / (MAX_ARG_STRLEN - 2); j++) |
3282 |
ap += sprintf (ap, "\\$\\{%u\\}", j); |
3283 |
*ap++ = '\\'; |
3284 |
*ap++ = '"'; |
3285 |
*ap++ = ' '; |
3286 |
/* Copy only the first word of SHELL to $0. */ |
3287 |
for (p = shell; *p != '\0'; ++p) |
3288 |
{ |
3289 |
if (isspace ((unsigned char)*p)) |
3290 |
break; |
3291 |
*ap++ = *p; |
3292 |
} |
3293 |
*ap++ = ' '; |
3294 |
} |
3295 |
#endif |
3296 |
args_ptr = ap; |
3297 |
|
3256 |
for (p = line; *p != '\0'; ++p) |
3298 |
for (p = line; *p != '\0'; ++p) |
3257 |
{ |
3299 |
{ |
3258 |
if (restp != NULL && *p == '\n') |
3300 |
if (restp != NULL && *p == '\n') |
Lines 3300-3305
construct_command_argv_internal (char *line, char **restp, char *shell,
Link Here
|
3300 |
} |
3342 |
} |
3301 |
#endif |
3343 |
#endif |
3302 |
*ap++ = *p; |
3344 |
*ap++ = *p; |
|
|
3345 |
#if !defined (WINDOWS32) && defined (MAX_ARG_STRLEN) |
3346 |
if (unixy_shell && line_len > MAX_ARG_STRLEN && (ap - args_ptr > MAX_ARG_STRLEN - 2)) |
3347 |
{ |
3348 |
*ap++ = ' '; |
3349 |
args_ptr = ap; |
3350 |
} |
3351 |
#endif |
3303 |
} |
3352 |
} |
3304 |
if (ap == new_line + shell_len + sflags_len + 2) |
3353 |
if (ap == new_line + shell_len + sflags_len + 2) |
3305 |
{ |
3354 |
{ |
3306 |
- |
|
|