* Copy out argument and environment strings from the old process address * space into the temporary string buffer. */
| 1153 | * space into the temporary string buffer. |
| 1154 | */ |
| 1155 | int |
| 1156 | exec_copyin_args(struct image_args *args, const char *fname, |
| 1157 | enum uio_seg segflg, char **argv, char **envv) |
| 1158 | { |
| 1159 | u_long arg, env; |
| 1160 | int error; |
| 1161 | |
| 1162 | bzero(args, sizeof(*args)); |
| 1163 | if (argv == NULL) |
| 1164 | return (EFAULT); |
| 1165 | |
| 1166 | /* |
| 1167 | * Allocate demand-paged memory for the file name, argument, and |
| 1168 | * environment strings. |
| 1169 | */ |
| 1170 | error = exec_alloc_args(args); |
| 1171 | if (error != 0) |
| 1172 | return (error); |
| 1173 | |
| 1174 | /* |
| 1175 | * Copy the file name. |
| 1176 | */ |
| 1177 | error = exec_args_add_fname(args, fname, segflg); |
| 1178 | if (error != 0) |
| 1179 | goto err_exit; |
| 1180 | |
| 1181 | /* |
| 1182 | * extract arguments first |
| 1183 | */ |
| 1184 | for (;;) { |
| 1185 | error = fueword(argv++, &arg); |
| 1186 | if (error == -1) { |
| 1187 | error = EFAULT; |
| 1188 | goto err_exit; |
| 1189 | } |
| 1190 | if (arg == 0) |
| 1191 | break; |
| 1192 | error = exec_args_add_arg(args, (char *)(uintptr_t)arg, |
| 1193 | UIO_USERSPACE); |
| 1194 | if (error != 0) |
| 1195 | goto err_exit; |
| 1196 | } |
| 1197 | |
| 1198 | /* |
| 1199 | * extract environment strings |
| 1200 | */ |
| 1201 | if (envv) { |
| 1202 | for (;;) { |
| 1203 | error = fueword(envv++, &env); |
| 1204 | if (error == -1) { |
| 1205 | error = EFAULT; |
| 1206 | goto err_exit; |
| 1207 | } |
| 1208 | if (env == 0) |
| 1209 | break; |
| 1210 | error = exec_args_add_env(args, |
| 1211 | (char *)(uintptr_t)env, UIO_USERSPACE); |
| 1212 | if (error != 0) |
no test coverage detected