net: properly handle illegal fd/vhostfd from command line

When hanlding fd/vhostfd form command line through net_handle_fd_param(),
we need to check mon and return value of strtol() otherwise we could
get segmentation fault or invalid fd when user type an illegal fd/vhostfd.

This patch is based on the suggestions from
Luiz Capitulino <lcapitulino@redhat.com>.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 file changed
tree: ac33e75ca51852177093bd88b4d84727cf83f1a9
  1. audio/
  2. block/
  3. bsd-user/
  4. darwin-user/
  5. default-configs/
  6. docs/
  7. fpu/
  8. fsdev/
  9. gdb-xml/
  10. hw/
  11. linux-user/
  12. net/
  13. pc-bios/
  14. QMP/
  15. roms/
  16. slirp/
  17. sysconfigs/
  18. target-alpha/
  19. target-arm/
  20. target-cris/
  21. target-i386/
  22. target-m68k/
  23. target-microblaze/
  24. target-mips/
  25. target-ppc/
  26. target-s390x/
  27. target-sh4/
  28. target-sparc/
  29. tcg/
  30. tests/
  31. ui/
  32. .gitignore
  33. .gitmodules
  34. a.out.h
  35. acl.c
  36. acl.h
  37. aes.c
  38. aes.h
  39. aio.c
  40. alpha-dis.c
  41. alpha.ld
  42. arch_init.c
  43. arch_init.h
  44. arm-dis.c
  45. arm-semi.c
  46. arm.ld
  47. async.c
  48. balloon.c
  49. balloon.h
  50. block-migration.c
  51. block-migration.h
  52. block.c
  53. block.h
  54. block_int.h
  55. blockdev.c
  56. blockdev.h
  57. bswap.h
  58. bt-host.c
  59. bt-host.h
  60. bt-vhci.c
  61. buffered_file.c
  62. buffered_file.h
  63. cache-utils.c
  64. cache-utils.h
  65. Changelog
  66. check-qdict.c
  67. check-qfloat.c
  68. check-qint.c
  69. check-qjson.c
  70. check-qlist.c
  71. check-qstring.c
  72. cmd.c
  73. cmd.h
  74. CODING_STYLE
  75. compatfd.c
  76. compatfd.h
  77. config.h
  78. configure
  79. console.c
  80. console.h
  81. COPYING
  82. COPYING.LIB
  83. cpu-all.h
  84. cpu-common.h
  85. cpu-defs.h
  86. cpu-exec.c
  87. cpus.c
  88. cpus.h
  89. create_config
  90. cris-dis.c
  91. cursor.c
  92. cursor_hidden.xpm
  93. cursor_left_ptr.xpm
  94. cutils.c
  95. def-helper.h
  96. device_tree.c
  97. device_tree.h
  98. dis-asm.h
  99. disas.c
  100. disas.h
  101. dma-helpers.c
  102. dma.h
  103. dyngen-exec.h
  104. elf.h
  105. envlist.c
  106. envlist.h
  107. exec-all.h
  108. exec.c
  109. feature_to_c.sh
  110. gdbstub.c
  111. gdbstub.h
  112. gen-icount.h
  113. HACKING
  114. hmp-commands.hx
  115. host-utils.c
  116. host-utils.h
  117. hpet.h
  118. hppa-dis.c
  119. hppa.ld
  120. hxtool
  121. i386-dis.c
  122. i386.ld
  123. ia64-dis.c
  124. ia64.ld
  125. input.c
  126. ioport-user.c
  127. ioport.c
  128. ioport.h
  129. iov.c
  130. iov.h
  131. json-lexer.c
  132. json-lexer.h
  133. json-parser.c
  134. json-parser.h
  135. json-streamer.c
  136. json-streamer.h
  137. kvm-all.c
  138. kvm-stub.c
  139. kvm.h
  140. libfdt_env.h
  141. LICENSE
  142. linux-aio.c
  143. m68k-dis.c
  144. m68k-semi.c
  145. m68k.ld
  146. MAINTAINERS
  147. Makefile
  148. Makefile.dis
  149. Makefile.hw
  150. Makefile.objs
  151. Makefile.target
  152. Makefile.user
  153. microblaze-dis.c
  154. migration-exec.c
  155. migration-fd.c
  156. migration-tcp.c
  157. migration-unix.c
  158. migration.c
  159. migration.h
  160. mips-dis.c
  161. mips.ld
  162. module.c
  163. module.h
  164. monitor.c
  165. monitor.h
  166. nbd.c
  167. nbd.h
  168. net-checksum.c
  169. net.c
  170. net.h
  171. notify.c
  172. notify.h
  173. os-posix.c
  174. os-win32.c
  175. osdep.c
  176. osdep.h
  177. path.c
  178. pci-ids.txt
  179. pflib.c
  180. pflib.h
  181. poison.h
  182. posix-aio-compat.c
  183. ppc-dis.c
  184. ppc.ld
  185. ppc64.ld
  186. qbool.c
  187. qbool.h
  188. qdict-test-data.txt
  189. qdict.c
  190. qdict.h
  191. qemu-aio.h
  192. qemu-barrier.h
  193. qemu-binfmt-conf.sh
  194. qemu-char.c
  195. qemu-char.h
  196. qemu-common.h
  197. qemu-config.c
  198. qemu-config.h
  199. qemu-doc.texi
  200. qemu-error.c
  201. qemu-error.h
  202. qemu-img-cmds.hx
  203. qemu-img.c
  204. qemu-img.texi
  205. qemu-io.c
  206. qemu-lock.h
  207. qemu-log.h
  208. qemu-malloc.c
  209. qemu-nbd.c
  210. qemu-nbd.texi
  211. qemu-objects.h
  212. qemu-option.c
  213. qemu-option.h
  214. qemu-options.h
  215. qemu-options.hx
  216. qemu-os-posix.h
  217. qemu-os-win32.h
  218. qemu-queue.h
  219. qemu-sockets.c
  220. qemu-tech.texi
  221. qemu-thread.c
  222. qemu-thread.h
  223. qemu-timer-common.c
  224. qemu-timer.c
  225. qemu-timer.h
  226. qemu-tool.c
  227. qemu-x509.h
  228. qemu.sasl
  229. qemu_socket.h
  230. qerror.c
  231. qerror.h
  232. qfloat.c
  233. qfloat.h
  234. qint.c
  235. qint.h
  236. qjson.c
  237. qjson.h
  238. qlist.c
  239. qlist.h
  240. qmp-commands.hx
  241. qobject.h
  242. qstring.c
  243. qstring.h
  244. range.h
  245. readline.c
  246. readline.h
  247. README
  248. rules.mak
  249. rwhandler.c
  250. rwhandler.h
  251. s390-dis.c
  252. s390.ld
  253. savevm.c
  254. sh4-dis.c
  255. simpletrace.c
  256. simpletrace.h
  257. simpletrace.py
  258. softmmu-semi.h
  259. softmmu_defs.h
  260. softmmu_exec.h
  261. softmmu_header.h
  262. softmmu_template.h
  263. sparc-dis.c
  264. sparc.ld
  265. sparc64.ld
  266. sysemu.h
  267. targphys.h
  268. tcg-runtime.c
  269. texi2pod.pl
  270. thunk.c
  271. thunk.h
  272. TODO
  273. trace-events
  274. tracetool
  275. translate-all.c
  276. uboot_image.h
  277. usb-bsd.c
  278. usb-linux.c
  279. usb-stub.c
  280. VERSION
  281. version.rc
  282. vgafont.h
  283. vl.c
  284. x86_64.ld