Пример #1
0
        /// <summary>
        ///	  Attempt to initialize IPC for the current platform, using identifier data
        ///	  passed via environment variables.
        /// </summary>
        public FuzzerIpc()
        {
            var shmId         = Environment.GetEnvironmentVariable("__LIBFUZZER_SHM_ID");
            var statusPipeId  = Environment.GetEnvironmentVariable("__LIBFUZZER_STATUS_PIPE_ID");
            var controlPipeId = Environment.GetEnvironmentVariable("__LIBFUZZER_CONTROL_PIPE_ID");

            if (shmId == null || statusPipeId == null || controlPipeId == null)
            {
                throw new FuzzerIpcEnvironmentException();
            }

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                impl = new WindowsFuzzerIpc(shmId, statusPipeId, controlPipeId);
            }
            else
            {
                if (!Int32.TryParse(shmId, out var posixShmId))
                {
                    // The shared memory ID cannot be parsed as a 32-bit integer, which means it cannot
                    // have been the return value of `shmget(2)`, and cannot be passed to `shmat(2)`.
                    throw new FuzzerIpcEnvironmentException();
                }

                impl = new PosixFuzzerIpc(posixShmId, statusPipeId, controlPipeId);
            }
        }
Пример #2
0
 public FuzzerIpc(IFuzzerIpcImpl impl)
 {
     this.impl = impl;
 }