Commit fd5f393ababcf13db74dfd26e53650abe34dedd7
1 parent
4af984a7
Remove fixed length commandline buffers.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4111 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
31 additions
and
38 deletions
linux-user/main.c
... | ... | @@ -1945,7 +1945,7 @@ int main(int argc, char **argv) |
1945 | 1945 | char **target_environ, **wrk, **dst; |
1946 | 1946 | |
1947 | 1947 | if (argc <= 1) |
1948 | - usage(); | |
1948 | + usage(1); | |
1949 | 1949 | |
1950 | 1950 | /* init debug */ |
1951 | 1951 | cpu_set_log_filename(DEBUG_LOGFILE); |
... | ... | @@ -1983,7 +1983,7 @@ int main(int argc, char **argv) |
1983 | 1983 | r = argv[optind++]; |
1984 | 1984 | x86_stack_size = strtol(r, (char **)&r, 0); |
1985 | 1985 | if (x86_stack_size <= 0) |
1986 | - usage(); | |
1986 | + usage(1); | |
1987 | 1987 | if (*r == 'M') |
1988 | 1988 | x86_stack_size *= 1024 * 1024; |
1989 | 1989 | else if (*r == 'k' || *r == 'K') | ... | ... |
vl.c
... | ... | @@ -8202,21 +8202,21 @@ int main(int argc, char **argv) |
8202 | 8202 | const char *boot_devices = ""; |
8203 | 8203 | DisplayState *ds = &display_state; |
8204 | 8204 | int cyls, heads, secs, translation; |
8205 | - char net_clients[MAX_NET_CLIENTS][256]; | |
8205 | + const char *net_clients[MAX_NET_CLIENTS]; | |
8206 | 8206 | int nb_net_clients; |
8207 | 8207 | int hda_index; |
8208 | 8208 | int optind; |
8209 | 8209 | const char *r, *optarg; |
8210 | 8210 | CharDriverState *monitor_hd; |
8211 | - char monitor_device[128]; | |
8212 | - char serial_devices[MAX_SERIAL_PORTS][128]; | |
8211 | + const char *monitor_device; | |
8212 | + const char *serial_devices[MAX_SERIAL_PORTS]; | |
8213 | 8213 | int serial_device_index; |
8214 | - char parallel_devices[MAX_PARALLEL_PORTS][128]; | |
8214 | + const char *parallel_devices[MAX_PARALLEL_PORTS]; | |
8215 | 8215 | int parallel_device_index; |
8216 | 8216 | const char *loadvm = NULL; |
8217 | 8217 | QEMUMachine *machine; |
8218 | 8218 | const char *cpu_model; |
8219 | - char usb_devices[MAX_USB_CMDLINE][128]; | |
8219 | + const char *usb_devices[MAX_USB_CMDLINE]; | |
8220 | 8220 | int usb_devices_index; |
8221 | 8221 | int fds[2]; |
8222 | 8222 | const char *pid_file = NULL; |
... | ... | @@ -8270,16 +8270,16 @@ int main(int argc, char **argv) |
8270 | 8270 | kernel_cmdline = ""; |
8271 | 8271 | cyls = heads = secs = 0; |
8272 | 8272 | translation = BIOS_ATA_TRANSLATION_AUTO; |
8273 | - pstrcpy(monitor_device, sizeof(monitor_device), "vc"); | |
8273 | + monitor_device = "vc"; | |
8274 | 8274 | |
8275 | - pstrcpy(serial_devices[0], sizeof(serial_devices[0]), "vc"); | |
8275 | + serial_devices[0] = "vc"; | |
8276 | 8276 | for(i = 1; i < MAX_SERIAL_PORTS; i++) |
8277 | - serial_devices[i][0] = '\0'; | |
8277 | + serial_devices[i] = NULL; | |
8278 | 8278 | serial_device_index = 0; |
8279 | 8279 | |
8280 | - pstrcpy(parallel_devices[0], sizeof(parallel_devices[0]), "vc"); | |
8280 | + parallel_devices[0] = "vc"; | |
8281 | 8281 | for(i = 1; i < MAX_PARALLEL_PORTS; i++) |
8282 | - parallel_devices[i][0] = '\0'; | |
8282 | + parallel_devices[i] = NULL; | |
8283 | 8283 | parallel_device_index = 0; |
8284 | 8284 | |
8285 | 8285 | usb_devices_index = 0; |
... | ... | @@ -8435,9 +8435,9 @@ int main(int argc, char **argv) |
8435 | 8435 | } |
8436 | 8436 | break; |
8437 | 8437 | case QEMU_OPTION_nographic: |
8438 | - pstrcpy(serial_devices[0], sizeof(serial_devices[0]), "stdio"); | |
8439 | - pstrcpy(parallel_devices[0], sizeof(parallel_devices[0]), "null"); | |
8440 | - pstrcpy(monitor_device, sizeof(monitor_device), "stdio"); | |
8438 | + serial_devices[0] = "stdio"; | |
8439 | + parallel_devices[0] = "null"; | |
8440 | + monitor_device = "stdio"; | |
8441 | 8441 | nographic = 1; |
8442 | 8442 | break; |
8443 | 8443 | #ifdef CONFIG_CURSES |
... | ... | @@ -8505,9 +8505,7 @@ int main(int argc, char **argv) |
8505 | 8505 | fprintf(stderr, "qemu: too many network clients\n"); |
8506 | 8506 | exit(1); |
8507 | 8507 | } |
8508 | - pstrcpy(net_clients[nb_net_clients], | |
8509 | - sizeof(net_clients[0]), | |
8510 | - optarg); | |
8508 | + net_clients[nb_net_clients] = optarg; | |
8511 | 8509 | nb_net_clients++; |
8512 | 8510 | break; |
8513 | 8511 | #ifdef CONFIG_SLIRP |
... | ... | @@ -8642,15 +8640,14 @@ int main(int argc, char **argv) |
8642 | 8640 | break; |
8643 | 8641 | } |
8644 | 8642 | case QEMU_OPTION_monitor: |
8645 | - pstrcpy(monitor_device, sizeof(monitor_device), optarg); | |
8643 | + monitor_device = optarg; | |
8646 | 8644 | break; |
8647 | 8645 | case QEMU_OPTION_serial: |
8648 | 8646 | if (serial_device_index >= MAX_SERIAL_PORTS) { |
8649 | 8647 | fprintf(stderr, "qemu: too many serial ports\n"); |
8650 | 8648 | exit(1); |
8651 | 8649 | } |
8652 | - pstrcpy(serial_devices[serial_device_index], | |
8653 | - sizeof(serial_devices[0]), optarg); | |
8650 | + serial_devices[serial_device_index] = optarg; | |
8654 | 8651 | serial_device_index++; |
8655 | 8652 | break; |
8656 | 8653 | case QEMU_OPTION_parallel: |
... | ... | @@ -8658,8 +8655,7 @@ int main(int argc, char **argv) |
8658 | 8655 | fprintf(stderr, "qemu: too many parallel ports\n"); |
8659 | 8656 | exit(1); |
8660 | 8657 | } |
8661 | - pstrcpy(parallel_devices[parallel_device_index], | |
8662 | - sizeof(parallel_devices[0]), optarg); | |
8658 | + parallel_devices[parallel_device_index] = optarg; | |
8663 | 8659 | parallel_device_index++; |
8664 | 8660 | break; |
8665 | 8661 | case QEMU_OPTION_loadvm: |
... | ... | @@ -8704,9 +8700,7 @@ int main(int argc, char **argv) |
8704 | 8700 | fprintf(stderr, "Too many USB devices\n"); |
8705 | 8701 | exit(1); |
8706 | 8702 | } |
8707 | - pstrcpy(usb_devices[usb_devices_index], | |
8708 | - sizeof(usb_devices[usb_devices_index]), | |
8709 | - optarg); | |
8703 | + usb_devices[usb_devices_index] = optarg; | |
8710 | 8704 | usb_devices_index++; |
8711 | 8705 | break; |
8712 | 8706 | case QEMU_OPTION_smp: |
... | ... | @@ -8894,10 +8888,8 @@ int main(int argc, char **argv) |
8894 | 8888 | /* init network clients */ |
8895 | 8889 | if (nb_net_clients == 0) { |
8896 | 8890 | /* if no clients, we use a default config */ |
8897 | - pstrcpy(net_clients[0], sizeof(net_clients[0]), | |
8898 | - "nic"); | |
8899 | - pstrcpy(net_clients[1], sizeof(net_clients[0]), | |
8900 | - "user"); | |
8891 | + net_clients[0] = "nic"; | |
8892 | + net_clients[1] = "user"; | |
8901 | 8893 | nb_net_clients = 2; |
8902 | 8894 | } |
8903 | 8895 | |
... | ... | @@ -9016,17 +9008,18 @@ int main(int argc, char **argv) |
9016 | 9008 | /* Maintain compatibility with multiple stdio monitors */ |
9017 | 9009 | if (!strcmp(monitor_device,"stdio")) { |
9018 | 9010 | for (i = 0; i < MAX_SERIAL_PORTS; i++) { |
9019 | - if (!strcmp(serial_devices[i],"mon:stdio")) { | |
9020 | - monitor_device[0] = '\0'; | |
9011 | + const char *devname = serial_devices[i]; | |
9012 | + if (devname && !strcmp(devname,"mon:stdio")) { | |
9013 | + monitor_device = NULL; | |
9021 | 9014 | break; |
9022 | - } else if (!strcmp(serial_devices[i],"stdio")) { | |
9023 | - monitor_device[0] = '\0'; | |
9024 | - pstrcpy(serial_devices[0], sizeof(serial_devices[0]), "mon:stdio"); | |
9015 | + } else if (devname && !strcmp(devname,"stdio")) { | |
9016 | + monitor_device = NULL; | |
9017 | + serial_devices[i] = "mon:stdio"; | |
9025 | 9018 | break; |
9026 | 9019 | } |
9027 | 9020 | } |
9028 | 9021 | } |
9029 | - if (monitor_device[0] != '\0') { | |
9022 | + if (monitor_device) { | |
9030 | 9023 | monitor_hd = qemu_chr_open(monitor_device); |
9031 | 9024 | if (!monitor_hd) { |
9032 | 9025 | fprintf(stderr, "qemu: could not open monitor device '%s'\n", monitor_device); |
... | ... | @@ -9037,7 +9030,7 @@ int main(int argc, char **argv) |
9037 | 9030 | |
9038 | 9031 | for(i = 0; i < MAX_SERIAL_PORTS; i++) { |
9039 | 9032 | const char *devname = serial_devices[i]; |
9040 | - if (devname[0] != '\0' && strcmp(devname, "none")) { | |
9033 | + if (devname && strcmp(devname, "none")) { | |
9041 | 9034 | serial_hds[i] = qemu_chr_open(devname); |
9042 | 9035 | if (!serial_hds[i]) { |
9043 | 9036 | fprintf(stderr, "qemu: could not open serial device '%s'\n", |
... | ... | @@ -9051,7 +9044,7 @@ int main(int argc, char **argv) |
9051 | 9044 | |
9052 | 9045 | for(i = 0; i < MAX_PARALLEL_PORTS; i++) { |
9053 | 9046 | const char *devname = parallel_devices[i]; |
9054 | - if (devname[0] != '\0' && strcmp(devname, "none")) { | |
9047 | + if (devname && strcmp(devname, "none")) { | |
9055 | 9048 | parallel_hds[i] = qemu_chr_open(devname); |
9056 | 9049 | if (!parallel_hds[i]) { |
9057 | 9050 | fprintf(stderr, "qemu: could not open parallel device '%s'\n", | ... | ... |