void Filter::onUpstreamEvent(Network::ConnectionEvent event) {
  // Update the connecting flag before processing the event because we may start a new connection
  // attempt in initializeUpstreamConnection.
  bool connecting = connecting_;
  connecting_ = false;

  if (event == Network::ConnectionEvent::RemoteClose ||
      event == Network::ConnectionEvent::LocalClose) {
    upstream_.reset();
    disableIdleTimer();

    if (connecting) {
      if (event == Network::ConnectionEvent::RemoteClose) {
        getStreamInfo().setResponseFlag(StreamInfo::ResponseFlag::UpstreamConnectionFailure);
        read_callbacks_->upstreamHost()->outlierDetector().putResult(
            Upstream::Outlier::Result::LocalOriginConnectFailed);
      }

      initializeUpstreamConnection();
    } else {
      if (read_callbacks_->connection().state() == Network::Connection::State::Open) {
        read_callbacks_->connection().close(Network::ConnectionCloseType::FlushWrite);
      }
    }
  }
}


static void check_initial_width ( VP9_COMP * cpi , int subsampling_x , int subsampling_y ) {
 VP9_COMMON * const cm = & cpi -> common ;
 if ( ! cpi -> initial_width ) {
 cm -> subsampling_x = subsampling_x ;
 cm -> subsampling_y = subsampling_y ;
 alloc_raw_frame_buffers ( cpi ) ;
 alloc_ref_frame_buffers ( cpi ) ;
 alloc_util_frame_buffers ( cpi ) ;
 init_motion_estimation ( cpi ) ;
 cpi -> initial_width = cm -> width ;
 cpi -> initial_height = cm -> height ;
 }
 }


SocketAddressLegacy *socket_parse(const char *str, Error **errp) { SocketAddressLegacy *addr; addr = g_new0(SocketAddressLegacy, 1); if (strstart(str, "unix:", NULL)) { if (str[5] == '\0') { error_setg(errp, "invalid Unix socket address"); goto fail; } else { addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX; addr->u.q_unix.data = g_new(UnixSocketAddress, 1); addr->u.q_unix.data->path = g_strdup(str + 5); } } else if (strstart(str, "fd:", NULL)) { if (str[3] == '\0') { error_setg(errp, "invalid file descriptor address"); goto fail; } else { addr->type = SOCKET_ADDRESS_LEGACY_KIND_FD; addr->u.fd.data = g_new(String, 1); addr->u.fd.data->str = g_strdup(str + 3); } } else if (strstart(str, "vsock:", NULL)) { addr->type = SOCKET_ADDRESS_LEGACY_KIND_VSOCK; addr->u.vsock.data = g_new(VsockSocketAddress, 1); if (vsock_parse(addr->u.vsock.data, str + strlen("vsock:"), errp)) { goto fail; } } else { addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET; addr->u.inet.data = g_new(InetSocketAddress, 1); if (inet_parse(addr->u.inet.data, str, errp)) { goto fail; } } return addr; fail: qapi_free_SocketAddressLegacy(addr); return NULL; }


static void do_info_cpus(Monitor *mon, QObject **ret_data) { CPUState *env; QList *cpu_list; cpu_list = qlist_new(); /* just to set the default cpu if not already done */ mon_get_cpu(); for(env = first_cpu; env != NULL; env = env->next_cpu) { QDict *cpu; QObject *obj; cpu_synchronize_state(env); obj = qobject_from_jsonf("{ 'CPU': %d, 'current': %i, 'halted': %i }", env->cpu_index, env == mon->mon_cpu, env->halted); assert(obj != NULL); cpu = qobject_to_qdict(obj); #if defined(TARGET_I386) qdict_put(cpu, "pc", qint_from_int(env->eip + env->segs[R_CS].base)); #elif defined(TARGET_PPC) qdict_put(cpu, "nip", qint_from_int(env->nip)); #elif defined(TARGET_SPARC) qdict_put(cpu, "pc", qint_from_int(env->pc)); qdict_put(cpu, "npc", qint_from_int(env->npc)); #elif defined(TARGET_MIPS) qdict_put(cpu, "PC", qint_from_int(env->active_tc.PC)); #endif qlist_append(cpu_list, cpu); } *ret_data = QOBJECT(cpu_list); }


static const char *dd_check(struct dump_dir *dd)
{
    unsigned dirname_len = strlen(dd->dd_dirname);
    char filename_buf[FILENAME_MAX+1];
    strcpy(filename_buf, dd->dd_dirname);
    strcpy(filename_buf + dirname_len, "/"FILENAME_TIME);
    dd->dd_time = parse_time_file(filename_buf);
    if (dd->dd_time < 0)
    {
        log_warning("Missing file: "FILENAME_TIME);
        return FILENAME_TIME;
    }

    strcpy(filename_buf + dirname_len, "/"FILENAME_TYPE);
    dd->dd_type = load_text_file(filename_buf, DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE);
    if (!dd->dd_type || (strlen(dd->dd_type) == 0))
    {
        log_warning("Missing or empty file: "FILENAME_TYPE);
        return FILENAME_TYPE;
    }

    return NULL;
}


void problem_data_load_from_dump_dir(problem_data_t *problem_data, struct dump_dir *dd, char **excluding)
{
    char *short_name;
    char *full_name;

    dd_init_next_file(dd);
    while (dd_get_next_file(dd, &short_name, &full_name))
    {
        if (excluding && is_in_string_list(short_name, excluding))
        {
            //log("Excluded:'%s'", short_name);
            goto next;
        }

        if (short_name[0] == '#'
         || (short_name[0] && short_name[strlen(short_name) - 1] == '~')
        ) {
            //log("Excluded (editor backup file):'%s'", short_name);
            goto next;
        }

        ssize_t sz = 4*1024;
        char *text = is_text_file(full_name, &sz);
        if (!text || text == HUGE_TEXT)
        {
            int flag = !text ? CD_FLAG_BIN : (CD_FLAG_BIN+CD_FLAG_BIGTXT);
            problem_data_add(problem_data,
                    short_name,
                    full_name,
                    flag + CD_FLAG_ISNOTEDITABLE
            );
            goto next;
        }

        char *content;
        if (sz < 4*1024) /* did is_text_file read entire file? */
        {
            /* yes */
            content = text;
        }
        else
        {
            /* no, need to read it all */
            free(text);
            content = dd_load_text(dd, short_name);
        }
        /* Strip '\n' from one-line elements: */
        char *nl = strchr(content, '\n');
        if (nl && nl[1] == '\0')
            *nl = '\0';

        /* Sanitize possibly corrupted utf8.
         * Of control chars, allow only tab and newline.
         */
        char *sanitized = sanitize_utf8(content,
                (SANITIZE_ALL & ~SANITIZE_LF & ~SANITIZE_TAB)
        );
        if (sanitized)
        {
            free(content);
            content = sanitized;
        }

        bool editable = is_editable_file(short_name);
        int flags = 0;
        if (editable)
            flags |= CD_FLAG_TXT | CD_FLAG_ISEDITABLE;
        else
            flags |= CD_FLAG_TXT | CD_FLAG_ISNOTEDITABLE;

        static const char *const list_files[] = {
            FILENAME_UID       ,
            FILENAME_PACKAGE   ,
            FILENAME_CMDLINE   ,
            FILENAME_TIME      ,
            FILENAME_COUNT     ,
            FILENAME_REASON    ,
            NULL
        };
        if (is_in_string_list(short_name, (char**)list_files))
            flags |= CD_FLAG_LIST;

        if (strcmp(short_name, FILENAME_TIME) == 0)
            flags |= CD_FLAG_UNIXTIME;

        problem_data_add(problem_data,
                short_name,
                content,
                flags
        );
        free(content);
 next:
        free(short_name);
        free(full_name);
    }
}


static QEMUFile *open_test_file(bool write) { int fd = dup(temp_fd); QIOChannel *ioc; lseek(fd, 0, SEEK_SET); if (write) { g_assert_cmpint(ftruncate(fd, 0), ==, 0); } ioc = QIO_CHANNEL(qio_channel_file_new_fd(fd)); if (write) { return qemu_fopen_channel_output(ioc); } else { return qemu_fopen_channel_input(ioc); } }


void dd_save_binary(struct dump_dir* dd, const char* name, const char* data, unsigned size)
{
    if (!dd->locked)
        error_msg_and_die("dump_dir is not opened"); /* bug */

    if (!str_is_correct_filename(name))
        error_msg_and_die("Cannot save binary. '%s' is not a valid file name", name);

    char *full_path = concat_path_file(dd->dd_dirname, name);
    save_binary_file(full_path, data, size, dd->dd_uid, dd->dd_gid, dd->mode);
    free(full_path);
}


struct dump_dir *dd_opendir(const char *dir, int flags)
{
    struct dump_dir *dd = dd_init();

    dir = dd->dd_dirname = rm_trailing_slashes(dir);

    struct stat stat_buf;
    if (stat(dir, &stat_buf) != 0)
        goto cant_access;
    /* & 0666 should remove the executable bit */
    dd->mode = (stat_buf.st_mode & 0666);

    errno = 0;
    if (dd_lock(dd, WAIT_FOR_OTHER_PROCESS_USLEEP, flags) < 0)
    {
        if ((flags & DD_OPEN_READONLY) && errno == EACCES)
        {
            /* Directory is not writable. If it seems to be readable,
             * return "read only" dd, not NULL */
            if (stat(dir, &stat_buf) == 0
             && S_ISDIR(stat_buf.st_mode)
             && access(dir, R_OK) == 0
            ) {
                if(dd_check(dd) != NULL)
                {
                    dd_close(dd);
                    dd = NULL;
                }
                return dd;
            }
        }
        if (errno == EISDIR)
        {
            /* EISDIR: dd_lock can lock the dir, but it sees no time file there,
             * even after it retried many times. It must be an ordinary directory!
             *
             * Without this check, e.g. abrt-action-print happily prints any current
             * directory when run without arguments, because its option -d DIR
             * defaults to "."!
             */
            error_msg("'%s' is not a problem directory", dir);
        }
        else
        {
 cant_access:
            if (errno == ENOENT || errno == ENOTDIR)
            {
                if (!(flags & DD_FAIL_QUIETLY_ENOENT))
                    error_msg("'%s' does not exist", dir);
            }
            else
            {
                if (!(flags & DD_FAIL_QUIETLY_EACCES))
                    perror_msg("Can't access '%s'", dir);
            }
        }
        dd_close(dd);
        return NULL;
    }

    dd->dd_uid = (uid_t)-1L;
    dd->dd_gid = (gid_t)-1L;
    if (geteuid() == 0)
    {
        /* In case caller would want to create more files, he'll need uid:gid */
        struct stat stat_buf;
        if (stat(dir, &stat_buf) != 0 || !S_ISDIR(stat_buf.st_mode))
        {
            error_msg("Can't stat '%s', or it is not a directory", dir);
            dd_close(dd);
            return NULL;
        }
        dd->dd_uid = stat_buf.st_uid;
        dd->dd_gid = stat_buf.st_gid;
    }

    return dd;
}


static void mspack_fmap_free ( void * mem ) {
 free ( mem ) ;
 }


static int device_open(AVFormatContext *ctx) { struct v4l2_capability cap; int fd; #if CONFIG_LIBV4L2 int fd_libv4l; #endif int res, err; int flags = O_RDWR; if (ctx->flags & AVFMT_FLAG_NONBLOCK) { flags |= O_NONBLOCK; } fd = v4l2_open(ctx->filename, flags, 0); if (fd < 0) { err = errno; av_log(ctx, AV_LOG_ERROR, "Cannot open video device %s : %s\n", ctx->filename, strerror(err)); return AVERROR(err); } #if CONFIG_LIBV4L2 fd_libv4l = v4l2_fd_open(fd, 0); if (fd < 0) { err = AVERROR(errno); av_log(ctx, AV_LOG_ERROR, "Cannot open video device with libv4l neither %s : %s\n", ctx->filename, strerror(errno)); return err; } fd = fd_libv4l; #endif res = v4l2_ioctl(fd, VIDIOC_QUERYCAP, &cap); if (res < 0) { err = errno; av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QUERYCAP): %s\n", strerror(err)); goto fail; } av_log(ctx, AV_LOG_VERBOSE, "[%d]Capabilities: %x\n", fd, cap.capabilities); if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) { av_log(ctx, AV_LOG_ERROR, "Not a video capture device.\n"); err = ENODEV; goto fail; } if (!(cap.capabilities & V4L2_CAP_STREAMING)) { av_log(ctx, AV_LOG_ERROR, "The device does not support the streaming I/O method.\n"); err = ENOSYS; goto fail; } return fd; fail: v4l2_close(fd); return AVERROR(err); }


long dd_get_item_size(struct dump_dir *dd, const char *name)
{
    if (!str_is_correct_filename(name))
        error_msg_and_die("Cannot get item size. '%s' is not a valid file name", name);

    long size = -1;
    char *iname = concat_path_file(dd->dd_dirname, name);
    struct stat statbuf;

    if (lstat(iname, &statbuf) == 0 && S_ISREG(statbuf.st_mode))
        size = statbuf.st_size;
    else
    {
        if (errno == ENOENT)
            size = 0;
        else
            perror_msg("Can't get size of file '%s'", iname);
    }

    free(iname);

    return size;
}


static int32_t u_printf_uinteger_handler ( const u_printf_stream_handler * handler , void * context , ULocaleBundle * formatBundle , const u_printf_spec_info * info , const ufmt_args * args ) {
 int64_t num = args [ 0 ] . int64Value ;
 UNumberFormat * format ;
 UChar result [ UPRINTF_BUFFER_SIZE ] ;
 int32_t minDigits = - 1 ;
 int32_t resultLen ;
 UErrorCode status = U_ZERO_ERROR ;
 if ( info -> fIsShort ) num &= UINT16_MAX ;
 else if ( ! info -> fIsLongLong ) num &= UINT32_MAX ;
 format = u_locbund_getNumberFormat ( formatBundle , UNUM_DECIMAL ) ;
 if ( format == 0 ) return 0 ;
 if ( info -> fPrecision != - 1 ) {
 minDigits = unum_getAttribute ( format , UNUM_MIN_INTEGER_DIGITS ) ;
 unum_setAttribute ( format , UNUM_MIN_INTEGER_DIGITS , info -> fPrecision ) ;
 }
 resultLen = unum_formatInt64 ( format , num , result , UPRINTF_BUFFER_SIZE , 0 , & status ) ;
 if ( U_FAILURE ( status ) ) {
 resultLen = 0 ;
 }
 if ( minDigits != - 1 ) {
 unum_setAttribute ( format , UNUM_MIN_INTEGER_DIGITS , minDigits ) ;
 }
 return handler -> pad_and_justify ( context , info , result , resultLen ) ;
 }


static char *load_text_file(const char *path, unsigned flags)
{
    int fd = open(path, O_RDONLY | ((flags & DD_OPEN_FOLLOW) ? 0 : O_NOFOLLOW));
    if (fd == -1)
    {
        if (!(flags & DD_FAIL_QUIETLY_ENOENT))
            perror_msg("Can't open file '%s'", path);
        return (flags & DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE ? NULL : xstrdup(""));
    }

    /* Why? Because half a million read syscalls of one byte each isn't fun.
     * FILE-based IO buffers reads.
     */
    FILE *fp = fdopen(fd, "r");
    if (!fp)
        die_out_of_memory();

    struct strbuf *buf_content = strbuf_new();
    int oneline = 0;
    int ch;
    while ((ch = fgetc(fp)) != EOF)
    {
//TODO? \r -> \n?
//TODO? strip trailing spaces/tabs?
        if (ch == '\n')
            oneline = (oneline << 1) | 1;
        if (ch == '\0')
            ch = ' ';
        if (isspace(ch) || ch >= ' ') /* used !iscntrl, but it failed on unicode */
            strbuf_append_char(buf_content, ch);
    }
    fclose(fp); /* this also closes fd */

    char last = oneline != 0 ? buf_content->buf[buf_content->len - 1] : 0;
    if (last == '\n')
    {
        /* If file contains exactly one '\n' and it is at the end, remove it.
         * This enables users to use simple "echo blah >file" in order to create
         * short string items in dump dirs.
         */
        if (oneline == 1)
            buf_content->buf[--buf_content->len] = '\0';
    }
    else /* last != '\n' */
    {
        /* Last line is unterminated, fix it */
        /* Cases: */
        /* oneline=0: "qwe" - DONT fix this! */
        /* oneline=1: "qwe\nrty" - two lines in fact */
        /* oneline>1: "qwe\nrty\uio" */
        if (oneline >= 1)
            strbuf_append_char(buf_content, '\n');
    }

    return strbuf_free_nobuf(buf_content);
}


void *av_realloc(void *ptr, unsigned int size) { #ifdef MEMALIGN_HACK //FIXME this isnt aligned correctly though it probably isnt needed int diff; if(!ptr) return av_malloc(size); diff= ((char*)ptr)[-1]; return realloc(ptr - diff, size + diff) + diff; #else return realloc(ptr, size); #endif }


static int dissect_h245_T_terminalIDResponse ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
 offset = dissect_per_sequence ( tvb , offset , actx , tree , hf_index , ett_h245_T_terminalIDResponse , T_terminalIDResponse_sequence ) ;
 return offset ;
 }


static void dd_unlock(struct dump_dir *dd)
{
    if (dd->locked)
    {
        dd->locked = 0;

        unsigned dirname_len = strlen(dd->dd_dirname);
        char lock_buf[dirname_len + sizeof("/.lock")];
        strcpy(lock_buf, dd->dd_dirname);
        strcpy(lock_buf + dirname_len, "/.lock");
        xunlink(lock_buf);

        log_info("Unlocked '%s'", lock_buf);
    }
}


void FullFramePixelBuffer::setBuffer(int width, int height,
                                     rdr::U8* data_, int stride_)
{
  if ((width < 0) || (width > maxPixelBufferWidth))
    throw rfb::Exception("Invalid PixelBuffer width of %d pixels requested", width);
  if ((height < 0) || (height > maxPixelBufferHeight))
    throw rfb::Exception("Invalid PixelBuffer height of %d pixels requested", height);
  if ((stride_ < 0) || (stride_ > maxPixelBufferStride) || (stride_ < width))
    throw rfb::Exception("Invalid PixelBuffer stride of %d pixels requested", stride_);
  if ((width != 0) && (height != 0) && (data_ == NULL))
    throw rfb::Exception("PixelBuffer requested without a valid memory area");

  ModifiablePixelBuffer::setSize(width, height);
  stride = stride_;
  data = data_;
}


void jbig2_word_stream_buf_free ( Jbig2Ctx * ctx , Jbig2WordStream * ws ) {
 jbig2_free ( ctx -> allocator , ws ) ;
 }


static OFCondition parseSCUSCPRole ( PRV_SCUSCPROLE * role , unsigned char * buf , unsigned long * length , unsigned long availData ) {
 unsigned short UIDLength ;
 if ( availData < 8 ) return makeLengthError ( "SCU-SCP role list" , availData , 8 ) ;
 role -> type = * buf ++ ;
 role -> rsv1 = * buf ++ ;
 EXTRACT_SHORT_BIG ( buf , role -> length ) ;
 buf += 2 ;
 EXTRACT_SHORT_BIG ( buf , UIDLength ) ;
 buf += 2 ;
 if ( availData - 4 < role -> length ) return makeLengthError ( "SCU-SCP role list" , availData , 0 , role -> length ) ;
 if ( role -> length < 4 ) return makeLengthError ( "SCU-SCP role list UID" , role -> length , 4 ) ;
 if ( role -> length - 4 < UIDLength ) return makeLengthError ( "SCU-SCP role list UID" , role -> length , 0 , UIDLength ) ;
 ( void ) memcpy ( role -> SOPClassUID , buf , UIDLength ) ;
 role -> SOPClassUID [ UIDLength ] = '\0' ;
 buf += UIDLength ;
 role -> SCURole = * buf ++ ;
 role -> SCPRole = * buf ++ ;
 * length = 2 + 2 + role -> length ;
 DCMNET_TRACE ( "Subitem parse: Type " << STD_NAMESPACE hex << STD_NAMESPACE setfill ( '0' ) << STD_NAMESPACE setw ( 2 ) << ( unsigned int ) role -> type << STD_NAMESPACE dec << ", Length " << STD_NAMESPACE setw ( 4 ) << ( int ) role -> length << ", Content: " << role -> SOPClassUID << " " << ( int ) role -> SCURole << " " << ( int ) role -> SCPRole ) ;
 return EC_Normal ;
 }


FdInStream::FdInStream(int fd_, FdInStreamBlockCallback* blockCallback_,
                       size_t bufSize_)
  : fd(fd_), timeoutms(0), blockCallback(blockCallback_),
    timing(false), timeWaitedIn100us(5), timedKbits(0),
    bufSize(bufSize_ ? bufSize_ : DEFAULT_BUF_SIZE), offset(0)
{
  ptr = end = start = new U8[bufSize];
}


size_t FdInStream::overrun(size_t itemSize, size_t nItems, bool wait)
{
  if (itemSize > bufSize)
    throw Exception("FdInStream overrun: max itemSize exceeded");

  if (end - ptr != 0)
    memmove(start, ptr, end - ptr);

  offset += ptr - start;
  end -= ptr - start;
  ptr = start;

  size_t bytes_to_read;
  while (end < start + itemSize) {
    bytes_to_read = start + bufSize - end;
    if (!timing) {
      // When not timing, we must be careful not to read too much
      // extra data into the buffer. Otherwise, the line speed
      // estimation might stay at zero for a long time: All reads
      // during timing=1 can be satisfied without calling
      // readWithTimeoutOrCallback. However, reading only 1 or 2 bytes
      // bytes is ineffecient.
      bytes_to_read = vncmin(bytes_to_read, vncmax(itemSize*nItems, 8));
    }
    size_t n = readWithTimeoutOrCallback((U8*)end, bytes_to_read, wait);
    if (n == 0) return 0;
    end += n;
  }

  if (itemSize * nItems > (size_t)(end - ptr))
    nItems = (end - ptr) / itemSize;

  return nItems;
}


void vp9_iht4x4_add ( TX_TYPE tx_type , const int16_t * input , uint8_t * dest , int stride , int eob ) {
 if ( tx_type == DCT_DCT ) vp9_idct4x4_add ( input , dest , stride , eob ) ;
 else vp9_iht4x4_16_add ( input , dest , stride , tx_type ) ;
 }


static void test_ivshmem_memdev(void) { IVState state; /* just for the sake of checking memory-backend property */ setup_vm_cmd(&state, "-object memory-backend-ram,size=1M,id=mb1" " -device ivshmem,x-memdev=mb1", false); qtest_quit(state.qtest); }


static inline int ip6_ufo_append_data(struct sock *sk,
			int getfrag(void *from, char *to, int offset, int len,
			int odd, struct sk_buff *skb),
			void *from, int length, int hh_len, int fragheaderlen,
			int transhdrlen, int mtu,unsigned int flags,
			struct rt6_info *rt)

{
	struct sk_buff *skb;
	int err;

	/* There is support for UDP large send offload by network
	 * device, so create one single skb packet containing complete
	 * udp datagram
	 */
	if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL) {
		struct frag_hdr fhdr;

		skb = sock_alloc_send_skb(sk,
			hh_len + fragheaderlen + transhdrlen + 20,
			(flags & MSG_DONTWAIT), &err);
		if (skb == NULL)
			return err;

		/* reserve space for Hardware header */
		skb_reserve(skb, hh_len);

		/* create space for UDP/IP header */
		skb_put(skb,fragheaderlen + transhdrlen);

		/* initialize network header pointer */
		skb_reset_network_header(skb);

		/* initialize protocol header pointer */
		skb->transport_header = skb->network_header + fragheaderlen;

		skb->protocol = htons(ETH_P_IPV6);
		skb->ip_summed = CHECKSUM_PARTIAL;
		skb->csum = 0;

		/* Specify the length of each IPv6 datagram fragment.
		 * It has to be a multiple of 8.
		 */
		skb_shinfo(skb)->gso_size = (mtu - fragheaderlen -
					     sizeof(struct frag_hdr)) & ~7;
		skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
		ipv6_select_ident(&fhdr, rt);
		skb_shinfo(skb)->ip6_frag_id = fhdr.identification;
		__skb_queue_tail(&sk->sk_write_queue, skb);
	}

	return skb_append_datato_frags(sk, skb, getfrag, from,
				       (length - transhdrlen));
}


void FdInStream::readBytes(void* data, size_t length)
{
  if (length < MIN_BULK_SIZE) {
    InStream::readBytes(data, length);
    return;
  }

  U8* dataPtr = (U8*)data;

  size_t n = end - ptr;
  if (n > length) n = length;

  memcpy(dataPtr, ptr, n);
  dataPtr += n;
  length -= n;
  ptr += n;

  while (length > 0) {
    n = readWithTimeoutOrCallback(dataPtr, length);
    dataPtr += n;
    length -= n;
    offset += n;
  }
}


int ide_init_drive(IDEState *s, BlockDriverState *bs, const char *version, const char *serial) { int cylinders, heads, secs; uint64_t nb_sectors; s->bs = bs; bdrv_get_geometry(bs, &nb_sectors); bdrv_guess_geometry(bs, &cylinders, &heads, &secs); if (cylinders < 1 || cylinders > 16383) { error_report("cyls must be between 1 and 16383"); if (heads < 1 || heads > 16) { error_report("heads must be between 1 and 16"); if (secs < 1 || secs > 63) { error_report("secs must be between 1 and 63"); s->cylinders = cylinders; s->heads = heads; s->sectors = secs; s->nb_sectors = nb_sectors; /* The SMART values should be preserved across power cycles but they aren't. */ s->smart_enabled = 1; s->smart_autosave = 1; s->smart_errors = 0; s->smart_selftest_count = 0; if (bdrv_get_type_hint(bs) == BDRV_TYPE_CDROM) { s->drive_kind = IDE_CD; bdrv_set_change_cb(bs, cdrom_change_cb, s); } else { if (bdrv_is_read_only(bs)) { error_report("Can't use a read-only drive"); if (serial) { strncpy(s->drive_serial_str, serial, sizeof(s->drive_serial_str)); } else { snprintf(s->drive_serial_str, sizeof(s->drive_serial_str), "QM%05d", s->drive_serial); if (version) { pstrcpy(s->version, sizeof(s->version), version); } else { pstrcpy(s->version, sizeof(s->version), QEMU_VERSION); ide_reset(s); bdrv_set_removable(bs, s->drive_kind == IDE_CD); return 0;


kadm5_ret_t kadm5_chpass_principal_3 ( void * server_handle , krb5_principal principal , krb5_boolean keepold , int n_ks_tuple , krb5_key_salt_tuple * ks_tuple , char * password ) {
 krb5_int32 now ;
 kadm5_policy_ent_rec pol ;
 osa_princ_ent_rec adb ;
 krb5_db_entry * kdb ;
 int ret , ret2 , last_pwd , hist_added ;
 krb5_boolean have_pol = FALSE ;
 kadm5_server_handle_t handle = server_handle ;
 osa_pw_hist_ent hist ;
 krb5_keyblock * act_mkey , * hist_keyblocks = NULL ;
 krb5_kvno act_kvno , hist_kvno ;
 int new_n_ks_tuple = 0 ;
 krb5_key_salt_tuple * new_ks_tuple = NULL ;
 CHECK_HANDLE ( server_handle ) ;
 krb5_clear_error_message ( handle -> context ) ;
 hist_added = 0 ;
 memset ( & hist , 0 , sizeof ( hist ) ) ;
 if ( principal == NULL || password == NULL ) return EINVAL ;
 if ( ( krb5_principal_compare ( handle -> context , principal , hist_princ ) ) == TRUE ) return KADM5_PROTECT_PRINCIPAL ;
 if ( ( ret = kdb_get_entry ( handle , principal , & kdb , & adb ) ) ) return ( ret ) ;
 ret = apply_keysalt_policy ( handle , adb . policy , n_ks_tuple , ks_tuple , & new_n_ks_tuple , & new_ks_tuple ) ;
 if ( ret ) goto done ;
 if ( ( adb . aux_attributes & KADM5_POLICY ) ) {
 ret = get_policy ( handle , adb . policy , & pol , & have_pol ) ;
 if ( ret ) goto done ;
 }
 if ( have_pol ) {
 ret = kdb_get_hist_key ( handle , & hist_keyblocks , & hist_kvno ) ;
 if ( ret ) goto done ;
 ret = create_history_entry ( handle -> context , & hist_keyblocks [ 0 ] , kdb -> n_key_data , kdb -> key_data , & hist ) ;
 if ( ret ) goto done ;
 }
 if ( ( ret = passwd_check ( handle , password , have_pol ? & pol : NULL , principal ) ) ) goto done ;
 ret = kdb_get_active_mkey ( handle , & act_kvno , & act_mkey ) ;
 if ( ret ) goto done ;
 ret = krb5_dbe_cpw ( handle -> context , act_mkey , new_ks_tuple , new_n_ks_tuple , password , 0 , keepold , kdb ) ;
 if ( ret ) goto done ;
 ret = krb5_dbe_update_mkvno ( handle -> context , kdb , act_kvno ) ;
 if ( ret ) goto done ;
 kdb -> attributes &= ~ KRB5_KDB_REQUIRES_PWCHANGE ;
 ret = krb5_timeofday ( handle -> context , & now ) ;
 if ( ret ) goto done ;
 if ( ( adb . aux_attributes & KADM5_POLICY ) ) {
 ret = krb5_dbe_lookup_last_pwd_change ( handle -> context , kdb , & last_pwd ) ;
 if ( ret ) goto done ;
 # if 0 if ( ( now - last_pwd ) < pol . pw_min_life && ! ( kdb -> attributes & KRB5_KDB_REQUIRES_PWCHANGE ) ) {
 ret = KADM5_PASS_TOOSOON ;
 goto done ;
 }
 # endif ret = check_pw_reuse ( handle -> context , hist_keyblocks , kdb -> n_key_data , kdb -> key_data , 1 , & hist ) ;
 if ( ret ) goto done ;
 if ( pol . pw_history_num > 1 ) {
 if ( adb . admin_history_kvno == hist_kvno ) {
 ret = check_pw_reuse ( handle -> context , hist_keyblocks , kdb -> n_key_data , kdb -> key_data , adb . old_key_len , adb . old_keys ) ;
 if ( ret ) goto done ;
 }
 ret = add_to_history ( handle -> context , hist_kvno , & adb , & pol , & hist ) ;
 if ( ret ) goto done ;
 hist_added = 1 ;
 }
 if ( pol . pw_max_life ) kdb -> pw_expiration = now + pol . pw_max_life ;
 else kdb -> pw_expiration = 0 ;
 }
 else {
 kdb -> pw_expiration = 0 ;
 }
 # ifdef USE_PASSWORD_SERVER if ( kadm5_use_password_server ( ) && ( krb5_princ_size ( handle -> context , principal ) == 1 ) ) {
 krb5_data * princ = krb5_princ_component ( handle -> context , principal , 0 ) ;
 const char * path = "/usr/sbin/mkpassdb" ;
 char * argv [ ] = {
 "mkpassdb" , "-setpassword" , NULL , NULL }
 ;
 char * pstring = NULL ;
 if ( ! ret ) {
 pstring = malloc ( ( princ -> length + 1 ) * sizeof ( char ) ) ;
 if ( pstring == NULL ) {
 ret = ENOMEM ;
 }
 }
 if ( ! ret ) {
 memcpy ( pstring , princ -> data , princ -> length ) ;
 pstring [ princ -> length ] = '\0' ;
 argv [ 2 ] = pstring ;
 ret = kadm5_launch_task ( handle -> context , path , argv , password ) ;
 }
 if ( pstring != NULL ) free ( pstring ) ;
 if ( ret ) goto done ;
 }
 # endif ret = krb5_dbe_update_last_pwd_change ( handle -> context , kdb , now ) ;
 if ( ret ) goto done ;
 kdb -> fail_auth_count = 0 ;
 kdb -> mask = KADM5_KEY_DATA | KADM5_ATTRIBUTES | KADM5_FAIL_AUTH_COUNT ;
 ret = k5_kadm5_hook_chpass ( handle -> context , handle -> hook_handles , KADM5_HOOK_STAGE_PRECOMMIT , principal , keepold , new_n_ks_tuple , new_ks_tuple , password ) ;
 if ( ret ) goto done ;
 if ( ( ret = kdb_put_entry ( handle , kdb , & adb ) ) ) goto done ;
 ( void ) k5_kadm5_hook_chpass ( handle -> context , handle -> hook_handles , KADM5_HOOK_STAGE_POSTCOMMIT , principal , keepold , new_n_ks_tuple , new_ks_tuple , password ) ;
 ret = KADM5_OK ;
 done : free ( new_ks_tuple ) ;
 if ( ! hist_added && hist . key_data ) free_history_entry ( handle -> context , & hist ) ;
 kdb_free_entry ( handle , kdb , & adb ) ;
 kdb_free_keyblocks ( handle , hist_keyblocks ) ;
 if ( have_pol && ( ret2 = kadm5_free_policy_ent ( handle -> lhandle , & pol ) ) && ! ret ) ret = ret2 ;
 return ret ;
 }


int FdOutStream::writeWithTimeout(const void* data, int length, int timeoutms)
{
  int n;

  do {
    fd_set fds;
    struct timeval tv;
    struct timeval* tvp = &tv;

    if (timeoutms != -1) {
      tv.tv_sec = timeoutms / 1000;
      tv.tv_usec = (timeoutms % 1000) * 1000;
    } else {
      tvp = NULL;
    }

    FD_ZERO(&fds);
    FD_SET(fd, &fds);
    n = select(fd+1, 0, &fds, 0, tvp);
  } while (n < 0 && errno == EINTR);

  if (n < 0)
    throw SystemException("select", errno);

  if (n == 0)
    return 0;

  do {
    // select only guarantees that you can write SO_SNDLOWAT without
    // blocking, which is normally 1. Use MSG_DONTWAIT to avoid
    // blocking, when possible.
#ifndef MSG_DONTWAIT
    n = ::send(fd, (const char*)data, length, 0);
#else
    n = ::send(fd, (const char*)data, length, MSG_DONTWAIT);
#endif
  } while (n < 0 && (errno == EINTR));

  if (n < 0)
    throw SystemException("write", errno);

  gettimeofday(&lastWrite, NULL);

  return n;
}


size_t FdOutStream::writeWithTimeout(const void* data, size_t length, int timeoutms)
{
  int n;

  do {
    fd_set fds;
    struct timeval tv;
    struct timeval* tvp = &tv;

    if (timeoutms != -1) {
      tv.tv_sec = timeoutms / 1000;
      tv.tv_usec = (timeoutms % 1000) * 1000;
    } else {
      tvp = NULL;
    }

    FD_ZERO(&fds);
    FD_SET(fd, &fds);
    n = select(fd+1, 0, &fds, 0, tvp);
  } while (n < 0 && errno == EINTR);

  if (n < 0)
    throw SystemException("select", errno);

  if (n == 0)
    return 0;

  do {
    // select only guarantees that you can write SO_SNDLOWAT without
    // blocking, which is normally 1. Use MSG_DONTWAIT to avoid
    // blocking, when possible.
#ifndef MSG_DONTWAIT
    n = ::send(fd, (const char*)data, length, 0);
#else
    n = ::send(fd, (const char*)data, length, MSG_DONTWAIT);
#endif
  } while (n < 0 && (errno == EINTR));

  if (n < 0)
    throw SystemException("write", errno);

  gettimeofday(&lastWrite, NULL);

  return n;
}


int TSMimeHdrFieldEqual ( TSMBuffer bufp , TSMLoc hdr_obj , TSMLoc field1_obj , TSMLoc field2_obj ) {
 sdk_assert ( sdk_sanity_check_mbuffer ( bufp ) == TS_SUCCESS ) ;
 sdk_assert ( sdk_sanity_check_field_handle ( field1_obj , hdr_obj ) == TS_SUCCESS ) ;
 sdk_assert ( sdk_sanity_check_field_handle ( field2_obj , hdr_obj ) == TS_SUCCESS ) ;
 MIMEFieldSDKHandle * field1_handle = ( MIMEFieldSDKHandle * ) field1_obj ;
 MIMEFieldSDKHandle * field2_handle = ( MIMEFieldSDKHandle * ) field2_obj ;
 if ( ( field1_handle == nullptr ) || ( field2_handle == nullptr ) ) {
 return ( field1_handle == field2_handle ) ;
 }
 return ( field1_handle -> field_ptr == field2_handle -> field_ptr ) ;
 }


int attribute_align_arg avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, uint8_t *buf, int buf_size) { int ret; if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){ //FIXME remove the check below _after_ ensuring that all audio check that the available space is enough if(*frame_size_ptr < AVCODEC_MAX_AUDIO_FRAME_SIZE){ av_log(avctx, AV_LOG_ERROR, "buffer smaller than AVCODEC_MAX_AUDIO_FRAME_SIZE\n"); return -1; } if(*frame_size_ptr < FF_MIN_BUFFER_SIZE || *frame_size_ptr < avctx->channels * avctx->frame_size * sizeof(int16_t) || *frame_size_ptr < buf_size){ av_log(avctx, AV_LOG_ERROR, "buffer %d too small\n", *frame_size_ptr); return -1; } ret = avctx->codec->decode(avctx, samples, frame_size_ptr, buf, buf_size); avctx->frame_number++; }else{ ret= 0; *frame_size_ptr=0; } return ret; }


get_one_option(int optid, const struct my_option *opt,
               char *argument)
{
  my_bool add_option= TRUE;

  switch (optid) {

  case '?':
    printf("%s  Ver %s Distrib %s, for %s (%s)\n",
           my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
    puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"));
    puts("MySQL utility for upgrading databases to new MySQL versions.\n");
    my_print_help(my_long_options);
    exit(0);
    break;

  case '#':
    DBUG_PUSH(argument ? argument : default_dbug_option);
    add_option= FALSE;
    debug_check_flag= 1;
    break;

  case 'p':
    if (argument == disabled_my_option)
      argument= (char*) "";			/* Don't require password */
    tty_password= 1;
    add_option= FALSE;
    if (argument)
    {
      /* Add password to ds_args before overwriting the arg with x's */
      add_one_option(&ds_args, opt, argument);
      while (*argument)
        *argument++= 'x';                       /* Destroy argument */
      tty_password= 0;
    }
    break;

  case 't':
    strnmov(opt_tmpdir, argument, sizeof(opt_tmpdir));
    add_option= FALSE;
    break;

  case 'b': /* --basedir   */
  case 'd': /* --datadir   */
    fprintf(stderr, "%s: the '--%s' option is always ignored\n",
            my_progname, optid == 'b' ? "basedir" : "datadir");
    /* FALLTHROUGH */

  case 'k':                                     /* --version-check */
  case 'v': /* --verbose   */
  case 'f': /* --force     */
  case 's':                                     /* --upgrade-system-tables */
  case OPT_WRITE_BINLOG:                        /* --write-binlog */
    add_option= FALSE;
    break;

  case 'h': /* --host */
  case 'W': /* --pipe */
  case 'P': /* --port */
  case 'S': /* --socket */
  case OPT_MYSQL_PROTOCOL: /* --protocol */
  case OPT_SHARED_MEMORY_BASE_NAME: /* --shared-memory-base-name */
  case OPT_PLUGIN_DIR:                          /* --plugin-dir */
  case OPT_DEFAULT_AUTH:                        /* --default-auth */
    add_one_option(&conn_args, opt, argument);
    break;
  }

  if (add_option)
  {
    /*
      This is an option that is accpted by mysql_upgrade just so
      it can be passed on to "mysql" and "mysqlcheck"
      Save it in the ds_args string
    */
    add_one_option(&ds_args, opt, argument);
  }
  return 0;
}


size_t HexInStream::overrun(size_t itemSize, size_t nItems, bool wait) {
  if (itemSize > bufSize)
    throw Exception("HexInStream overrun: max itemSize exceeded");

  if (end - ptr != 0)
    memmove(start, ptr, end - ptr);

  end -= ptr - start;
  offset += ptr - start;
  ptr = start;

  while (end < ptr + itemSize) {
    size_t n = in_stream.check(2, 1, wait);
    if (n == 0) return 0;
    const U8* iptr = in_stream.getptr();
    const U8* eptr = in_stream.getend();
    size_t length = min((eptr - iptr)/2, start + bufSize - end);

    U8* optr = (U8*) end;
    for (size_t i=0; i<length; i++) {
      int v = 0;
      readHexAndShift(iptr[i*2], &v);
      readHexAndShift(iptr[i*2+1], &v);
      optr[i] = v;
    }

    in_stream.setptr(iptr + length*2);
    end += length;
  }

  if (itemSize * nItems > (size_t)(end - ptr))
    nItems = (end - ptr) / itemSize;

  return nItems;
}


static int dissect_pcp_message_profile ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , int offset ) {
 proto_item * pcp_profile_item ;
 proto_tree * pcp_profile_tree ;
 proto_item * pcp_profile_profile_item ;
 proto_tree * pcp_profile_profile_tree ;
 guint32 num_prof ;
 guint32 i ;
 col_append_fstr ( pinfo -> cinfo , COL_INFO , "[%s]" , val_to_str ( PCP_PDU_PROFILE , packettypenames , "Unknown Type:0x%02x" ) ) ;
 pcp_profile_item = proto_tree_add_item ( tree , hf_pcp_profile , tvb , offset , - 1 , ENC_NA ) ;
 pcp_profile_tree = proto_item_add_subtree ( pcp_profile_item , ett_pcp ) ;
 proto_tree_add_item ( pcp_profile_tree , hf_pcp_ctxnum , tvb , offset , 4 , ENC_BIG_ENDIAN ) ;
 offset += 4 ;
 proto_tree_add_item ( pcp_profile_tree , hf_pcp_profile_g_state , tvb , offset , 4 , ENC_BIG_ENDIAN ) ;
 offset += 4 ;
 proto_tree_add_item ( pcp_profile_tree , hf_pcp_profile_numprof , tvb , offset , 4 , ENC_BIG_ENDIAN ) ;
 num_prof = tvb_get_ntohl ( tvb , offset ) ;
 offset += 4 ;
 proto_tree_add_item ( pcp_profile_tree , hf_pcp_pdu_padding , tvb , offset , 4 , ENC_NA ) ;
 offset += 4 ;
 for ( i = 0 ;
 i < num_prof ;
 i ++ ) {
 pcp_profile_profile_item = proto_tree_add_item ( pcp_profile_tree , hf_pcp_profile_profile , tvb , offset , 32 , ENC_NA ) ;
 pcp_profile_profile_tree = proto_item_add_subtree ( pcp_profile_profile_item , ett_pcp ) ;
 proto_tree_add_item ( pcp_profile_profile_tree , hf_pcp_instance_indom , tvb , offset , 4 , ENC_BIG_ENDIAN ) ;
 offset += 4 ;
 proto_tree_add_item ( pcp_profile_profile_tree , hf_pcp_profile_profile_state , tvb , offset , 4 , ENC_BIG_ENDIAN ) ;
 offset += 4 ;
 proto_tree_add_item ( pcp_profile_profile_tree , hf_pcp_profile_profile_numinst , tvb , offset , 4 , ENC_BIG_ENDIAN ) ;
 offset += 4 ;
 proto_tree_add_item ( pcp_profile_tree , hf_pcp_pdu_padding , tvb , offset , 4 , ENC_NA ) ;
 offset += 4 ;
 }
 return offset ;
 }


static int au1200fb_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)

{
	unsigned int len;
	unsigned long start=0, off;
	struct au1200fb_device *fbdev = info->par;

	if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) {
		return -EINVAL;
	}

	start = fbdev->fb_phys & PAGE_MASK;
	len = PAGE_ALIGN((start & ~PAGE_MASK) + fbdev->fb_len);

	off = vma->vm_pgoff << PAGE_SHIFT;

	if ((vma->vm_end - vma->vm_start + off) > len) {
		return -EINVAL;
	}

	off += start;
	vma->vm_pgoff = off >> PAGE_SHIFT;

	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
	pgprot_val(vma->vm_page_prot) |= _CACHE_MASK; /* CCA=7 */

	return io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
				  vma->vm_end - vma->vm_start,
				  vma->vm_page_prot);
}


static void selinux_sk_getsecid ( struct sock * sk , u32 * secid ) {
 if ( ! sk ) * secid = SECINITSID_ANY_SOCKET ;
 else {
 struct sk_security_struct * sksec = sk -> sk_security ;
 * secid = sksec -> sid ;
 }
 }


char* HexOutStream::binToHexStr(const char* data, int length) {
  char* buffer = new char[length*2+1];
  for (int i=0; i<length; i++) {
    buffer[i*2] = intToHex((data[i] >> 4) & 15);
    buffer[i*2+1] = intToHex((data[i] & 15));
    if (!buffer[i*2] || !buffer[i*2+1]) {
      delete [] buffer;
      return 0;
    }
  }
  buffer[length*2] = 0;
  return buffer;
}


int HexOutStream::length()
{
  return offset + ptr - start;
}


inline bool checkNoWait(int length) { return check(length, 1, false)!=0; }


XML_GetBuffer(XML_Parser parser, int len)
{
  switch (ps_parsing) {
  case XML_SUSPENDED:
    errorCode = XML_ERROR_SUSPENDED;
    return NULL;
  case XML_FINISHED:
    errorCode = XML_ERROR_FINISHED;
    return NULL;
  default: ;
  }

  if (len > bufferLim - bufferEnd) {
    /* FIXME avoid integer overflow */
    int neededSize = len + (int)(bufferEnd - bufferPtr);
#ifdef XML_CONTEXT_BYTES
    int keep = (int)(bufferPtr - buffer);

    if (keep > XML_CONTEXT_BYTES)
      keep = XML_CONTEXT_BYTES;
    neededSize += keep;
#endif  /* defined XML_CONTEXT_BYTES */
    if (neededSize  <= bufferLim - buffer) {
#ifdef XML_CONTEXT_BYTES
      if (keep < bufferPtr - buffer) {
        int offset = (int)(bufferPtr - buffer) - keep;
        memmove(buffer, &buffer[offset], bufferEnd - bufferPtr + keep);
        bufferEnd -= offset;
        bufferPtr -= offset;
      }
#else
      memmove(buffer, bufferPtr, bufferEnd - bufferPtr);
      bufferEnd = buffer + (bufferEnd - bufferPtr);
      bufferPtr = buffer;
#endif  /* not defined XML_CONTEXT_BYTES */
    }
    else {
      char *newBuf;
      int bufferSize = (int)(bufferLim - bufferPtr);
      if (bufferSize == 0)
        bufferSize = INIT_BUFFER_SIZE;
      do {
        bufferSize *= 2;
      } while (bufferSize < neededSize);
      newBuf = (char *)MALLOC(bufferSize);
      if (newBuf == 0) {
        errorCode = XML_ERROR_NO_MEMORY;
        return NULL;
      }
      bufferLim = newBuf + bufferSize;
#ifdef XML_CONTEXT_BYTES
      if (bufferPtr) {
        int keep = (int)(bufferPtr - buffer);
        if (keep > XML_CONTEXT_BYTES)
          keep = XML_CONTEXT_BYTES;
        memcpy(newBuf, &bufferPtr[-keep], bufferEnd - bufferPtr + keep);
        FREE(buffer);
        buffer = newBuf;
        bufferEnd = buffer + (bufferEnd - bufferPtr) + keep;
        bufferPtr = buffer + keep;
      }
      else {
        bufferEnd = newBuf + (bufferEnd - bufferPtr);
        bufferPtr = buffer = newBuf;
      }
#else
      if (bufferPtr) {
        memcpy(newBuf, bufferPtr, bufferEnd - bufferPtr);
        FREE(buffer);
      }
      bufferEnd = newBuf + (bufferEnd - bufferPtr);
      bufferPtr = buffer = newBuf;
#endif  /* not defined XML_CONTEXT_BYTES */
    }
    eventPtr = eventEndPtr = NULL;
    positionPtr = NULL;
  }
  return bufferEnd;
}


static int sse_mb(MpegEncContext *s){ int w= 16; int h= 16; if(s->mb_x*16 + 16 > s->width ) w= s->width - s->mb_x*16; if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16; if(w==16 && h==16) if(s->avctx->mb_cmp == FF_CMP_NSSE){ return s->dsp.nsse[0](s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16) +s->dsp.nsse[1](s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8) +s->dsp.nsse[1](s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8); }else{ return s->dsp.sse[0](NULL, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16) +s->dsp.sse[1](NULL, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8) +s->dsp.sse[1](NULL, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8); } else return sse(s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], w, h, s->linesize) +sse(s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], w>>1, h>>1, s->uvlinesize) +sse(s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], w>>1, h>>1, s->uvlinesize); }


SPL_METHOD(SplObjectStorage, serialize)
{
	spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);

	spl_SplObjectStorageElement *element;
	zval members, *pmembers, *flags;
	HashPosition      pos;
	php_serialize_data_t var_hash;
	smart_str buf = {0};

	if (zend_parse_parameters_none() == FAILURE) {
		return;
	}

	PHP_VAR_SERIALIZE_INIT(var_hash);

	/* storage */
	smart_str_appendl(&buf, "x:", 2);
	MAKE_STD_ZVAL(flags);
	ZVAL_LONG(flags, zend_hash_num_elements(&intern->storage));
	php_var_serialize(&buf, &flags, &var_hash TSRMLS_CC);
	zval_ptr_dtor(&flags);

	zend_hash_internal_pointer_reset_ex(&intern->storage, &pos);

	while(zend_hash_has_more_elements_ex(&intern->storage, &pos) == SUCCESS) {
		if (zend_hash_get_current_data_ex(&intern->storage, (void**)&element, &pos) == FAILURE) {
			smart_str_free(&buf);
			PHP_VAR_SERIALIZE_DESTROY(var_hash);
			RETURN_NULL();
		}
		php_var_serialize(&buf, &element->obj, &var_hash TSRMLS_CC);
		smart_str_appendc(&buf, ',');
		php_var_serialize(&buf, &element->inf, &var_hash TSRMLS_CC);
		smart_str_appendc(&buf, ';');
		zend_hash_move_forward_ex(&intern->storage, &pos);
	}

	/* members */
	smart_str_appendl(&buf, "m:", 2);
	INIT_PZVAL(&members);
	Z_ARRVAL(members) = zend_std_get_properties(getThis() TSRMLS_CC);
	Z_TYPE(members) = IS_ARRAY;
	zend_hash_del(Z_ARRVAL(members), "\x00gcdata", sizeof("\x00gcdata"));
	pmembers = &members;
	php_var_serialize(&buf, &pmembers, &var_hash TSRMLS_CC); /* finishes the string */

	/* done */
	PHP_VAR_SERIALIZE_DESTROY(var_hash);

	if (buf.c) {
		RETURN_STRINGL(buf.c, buf.len, 0);
	} else {
		RETURN_NULL();
	}

} /* }}} */


void spl_SplOjectStorage_free_storage(void *object TSRMLS_DC) /* {{{ */
{
	spl_SplObjectStorage *intern = (spl_SplObjectStorage *)object;

	zend_object_std_dtor(&intern->std TSRMLS_CC);

	zend_hash_destroy(&intern->storage);

	if (intern->debug_info != NULL) {
		zend_hash_destroy(intern->debug_info);
		efree(intern->debug_info);
	}

	efree(object);
} /* }}} */


static HashTable *spl_object_storage_get_gc(zval *obj, zval ***table, int *n TSRMLS_DC) /* {{{ */
{
	spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(obj TSRMLS_CC);
	spl_SplObjectStorageElement *element;
	HashTable *props;
	HashPosition pos;
	zval *gcdata_arr = NULL,
		 **gcdata_arr_pp;

	props = std_object_handlers.get_properties(obj TSRMLS_CC);

	*table = NULL;
	*n = 0;

	/* clean \x00gcdata, as it may be out of date */
	if (zend_hash_find(props, "\x00gcdata", sizeof("\x00gcdata"), (void**) &gcdata_arr_pp) == SUCCESS) {
		gcdata_arr = *gcdata_arr_pp;
		zend_hash_clean(Z_ARRVAL_P(gcdata_arr));
	}

	if (gcdata_arr == NULL) {
		MAKE_STD_ZVAL(gcdata_arr);
		array_init(gcdata_arr);
		/* don't decrease refcount of members when destroying */
		Z_ARRVAL_P(gcdata_arr)->pDestructor = NULL;

		/* name starts with \x00 to make tampering in user-land more difficult */
		zend_hash_add(props, "\x00gcdata", sizeof("\x00gcdata"), &gcdata_arr, sizeof(gcdata_arr), NULL);
	}

	zend_hash_internal_pointer_reset_ex(&intern->storage, &pos);
	while (zend_hash_get_current_data_ex(&intern->storage, (void **)&element, &pos) == SUCCESS) {
		add_next_index_zval(gcdata_arr, element->obj);
		add_next_index_zval(gcdata_arr, element->inf);
		zend_hash_move_forward_ex(&intern->storage, &pos);
	}

	return props;
}


struct file *get_empty_filp(void)
{
	const struct cred *cred = current_cred();
	static long old_max;
	struct file *f;
	int error;

	/*
	 * Privileged users can go above max_files
	 */
	if (get_nr_files() >= files_stat.max_files && !capable(CAP_SYS_ADMIN)) {
		/*
		 * percpu_counters are inaccurate.  Do an expensive check before
		 * we go and fail.
		 */
		if (percpu_counter_sum_positive(&nr_files) >= files_stat.max_files)
			goto over;
	}

	f = kmem_cache_zalloc(filp_cachep, GFP_KERNEL);
	if (unlikely(!f))
		return ERR_PTR(-ENOMEM);

	percpu_counter_inc(&nr_files);
	f->f_cred = get_cred(cred);
	error = security_file_alloc(f);
	if (unlikely(error)) {
		file_free(f);
		return ERR_PTR(error);
	}

	INIT_LIST_HEAD(&f->f_u.fu_list);
	atomic_long_set(&f->f_count, 1);
	rwlock_init(&f->f_owner.lock);
	spin_lock_init(&f->f_lock);
	eventpoll_init_file(f);
	/* f->f_version: 0 */
	return f;

over:
	/* Ran out of filps - report that */
	if (get_nr_files() > old_max) {
		pr_info("VFS: file-max limit %lu reached\n", get_max_files());
		old_max = get_nr_files();
	}
	return ERR_PTR(-ENFILE);
}


static TCGv_i32 gen_get_asi(DisasContext *dc, int insn) { int asi; if (IS_IMM) { #ifdef TARGET_SPARC64 asi = dc->asi; #else gen_exception(dc, TT_ILL_INSN); asi = 0; #endif } else { asi = GET_FIELD(insn, 19, 26); } return tcg_const_i32(asi); }


static int gx_ttfReader__default_get_metrics ( const ttfReader * ttf , uint glyph_index , bool bVertical , short * sideBearing , unsigned short * nAdvance ) {
 gx_ttfReader * self = ( gx_ttfReader * ) ttf ;
 float sbw [ 4 ] ;
 int sbw_offset = bVertical ;
 int code ;
 int factor = self -> pfont -> data . unitsPerEm ;
 code = self -> pfont -> data . get_metrics ( self -> pfont , glyph_index , bVertical , sbw ) ;
 if ( code < 0 ) return code ;
 * sideBearing = ( short ) floor ( sbw [ 0 + sbw_offset ] * factor + 0.5 ) ;
 * nAdvance = ( short ) floor ( sbw [ 2 + sbw_offset ] * factor + 0.5 ) ;
 return 0 ;
 }


void crypto_policy_set_rtp_default ( crypto_policy_t * p ) {
 p -> cipher_type = AES_ICM ;
 p -> cipher_key_len = 30 ;
 p -> auth_type = HMAC_SHA1 ;
 p -> auth_key_len = 20 ;
 p -> auth_tag_len = 10 ;
 p -> sec_serv = sec_serv_conf_and_auth ;
 }


static struct super_block *alloc_super(struct file_system_type *type, int flags)
{
	struct super_block *s = kzalloc(sizeof(struct super_block),  GFP_USER);
	static const struct super_operations default_op;
	int i;

	if (!s)
		return NULL;

	if (security_sb_alloc(s))
		goto fail;

#ifdef CONFIG_SMP
	s->s_files = alloc_percpu(struct list_head);
	if (!s->s_files)
		goto fail;
	for_each_possible_cpu(i)
		INIT_LIST_HEAD(per_cpu_ptr(s->s_files, i));
#else
	INIT_LIST_HEAD(&s->s_files);
#endif
	for (i = 0; i < SB_FREEZE_LEVELS; i++) {
		if (percpu_counter_init(&s->s_writers.counter[i], 0) < 0)
			goto fail;
		lockdep_init_map(&s->s_writers.lock_map[i], sb_writers_name[i],
				 &type->s_writers_key[i], 0);
	}
	init_waitqueue_head(&s->s_writers.wait);
	init_waitqueue_head(&s->s_writers.wait_unfrozen);
	s->s_flags = flags;
	s->s_bdi = &default_backing_dev_info;
	INIT_HLIST_NODE(&s->s_instances);
	INIT_HLIST_BL_HEAD(&s->s_anon);
	INIT_LIST_HEAD(&s->s_inodes);

	if (list_lru_init(&s->s_dentry_lru))
		goto fail;
	if (list_lru_init(&s->s_inode_lru))
		goto fail;

	INIT_LIST_HEAD(&s->s_mounts);
	init_rwsem(&s->s_umount);
	lockdep_set_class(&s->s_umount, &type->s_umount_key);
	/*
	 * sget() can have s_umount recursion.
	 *
	 * When it cannot find a suitable sb, it allocates a new
	 * one (this one), and tries again to find a suitable old
	 * one.
	 *
	 * In case that succeeds, it will acquire the s_umount
	 * lock of the old one. Since these are clearly distrinct
	 * locks, and this object isn't exposed yet, there's no
	 * risk of deadlocks.
	 *
	 * Annotate this by putting this lock in a different
	 * subclass.
	 */
	down_write_nested(&s->s_umount, SINGLE_DEPTH_NESTING);
	s->s_count = 1;
	atomic_set(&s->s_active, 1);
	mutex_init(&s->s_vfs_rename_mutex);
	lockdep_set_class(&s->s_vfs_rename_mutex, &type->s_vfs_rename_key);
	mutex_init(&s->s_dquot.dqio_mutex);
	mutex_init(&s->s_dquot.dqonoff_mutex);
	init_rwsem(&s->s_dquot.dqptr_sem);
	s->s_maxbytes = MAX_NON_LFS;
	s->s_op = &default_op;
	s->s_time_gran = 1000000000;
	s->cleancache_poolid = -1;

	s->s_shrink.seeks = DEFAULT_SEEKS;
	s->s_shrink.scan_objects = super_cache_scan;
	s->s_shrink.count_objects = super_cache_count;
	s->s_shrink.batch = 1024;
	s->s_shrink.flags = SHRINKER_NUMA_AWARE;
	return s;

fail:
	destroy_super(s);
	return NULL;
}


    size_t overrun(size_t itemSize, size_t nItems) {
      size_t len = ptr - start + itemSize * nItems;
      if (len < (size_t)(end - start) * 2)
        len = (end - start) * 2;

      U8* newStart = new U8[len];
      memcpy(newStart, start, ptr - start);
      ptr = newStart + (ptr - start);
      delete [] start;
      start = newStart;
      end = newStart + len;

      return nItems;
    }


static int dissect_h225_SEQUENCE_OF_AuthenticationMechanism ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
 offset = dissect_per_sequence_of ( tvb , offset , actx , tree , hf_index , ett_h225_SEQUENCE_OF_AuthenticationMechanism , SEQUENCE_OF_AuthenticationMechanism_sequence_of ) ;
 return offset ;
 }


static void encode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride, int plane_index) { int x, y, i; const int ring_size = s->avctx->context_model ? 3 : 2; int16_t *sample[3]; s->run_index = 0; memset(s->sample_buffer, 0, ring_size * (w + 6) * sizeof(*s->sample_buffer)); for (y = 0; y < h; y++) { for (i = 0; i < ring_size; i++) sample[i] = s->sample_buffer + (w + 6) * ((h + i - y) % ring_size) + 3; sample[0][-1]= sample[1][0 ]; sample[1][ w]= sample[1][w-1]; // { START_TIMER if (s->bits_per_raw_sample <= 8) { for (x = 0; x < w; x++) sample[0][x] = src[x + stride * y]; encode_line(s, w, sample, plane_index, 8); } else { if (s->packed_at_lsb) { for (x = 0; x < w; x++) { sample[0][x] = ((uint16_t*)(src + stride*y))[x]; } } else { for (x = 0; x < w; x++) { sample[0][x] = ((uint16_t*)(src + stride*y))[x] >> (16 - s->bits_per_raw_sample); } } encode_line(s, w, sample, plane_index, s->bits_per_raw_sample); } // STOP_TIMER("encode line") } } }


static int decode_plane(Indeo3DecodeContext *ctx, AVCodecContext *avctx, Plane *plane, const uint8_t *data, int32_t data_size, int32_t strip_width) { Cell curr_cell; int num_vectors; /* each plane data starts with mc_vector_count field, */ /* an optional array of motion vectors followed by the vq data */ num_vectors = bytestream_get_le32(&data); ctx->mc_vectors = num_vectors ? data : 0; /* init the bitreader */ init_get_bits(&ctx->gb, &data[num_vectors * 2], data_size << 3); ctx->skip_bits = 0; ctx->need_resync = 0; ctx->last_byte = data + data_size - 1; /* initialize the 1st cell and set its dimensions to whole plane */ curr_cell.xpos = curr_cell.ypos = 0; curr_cell.width = plane->width >> 2; curr_cell.height = plane->height >> 2; curr_cell.tree = 0; // we are in the MC tree now curr_cell.mv_ptr = 0; // no motion vector = INTRA cell return parse_bintree(ctx, avctx, plane, INTRA_NULL, &curr_cell, CELL_STACK_MAX, strip_width); }


    void writeBytes(const void* data, int length) {
      check(length);
      memcpy(ptr, data, length);
      ptr += length;
    }


static guint16 de_clg_party_bcd_num ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo , guint32 offset , guint len , gchar * add_string , int string_len ) {
 const gchar * extr_addr ;
 de_bcd_num ( tvb , tree , pinfo , offset , len , hf_gsm_a_dtap_clg_party_bcd_num , & extr_addr ) ;
 if ( extr_addr && add_string ) g_snprintf ( add_string , string_len , " - (%s)" , extr_addr ) ;
 return ( len ) ;
 }


static int __ptrace_may_access(struct task_struct *task, unsigned int mode)
{
	const struct cred *cred = current_cred(), *tcred;

	/* May we inspect the given task?
	 * This check is used both for attaching with ptrace
	 * and for allowing access to sensitive information in /proc.
	 *
	 * ptrace_attach denies several cases that /proc allows
	 * because setting up the necessary parent/child relationship
	 * or halting the specified task is impossible.
	 */
	int dumpable = 0;
	/* Don't let security modules deny introspection */
	if (same_thread_group(task, current))
		return 0;
	rcu_read_lock();
	tcred = __task_cred(task);
	if (uid_eq(cred->uid, tcred->euid) &&
	    uid_eq(cred->uid, tcred->suid) &&
	    uid_eq(cred->uid, tcred->uid)  &&
	    gid_eq(cred->gid, tcred->egid) &&
	    gid_eq(cred->gid, tcred->sgid) &&
	    gid_eq(cred->gid, tcred->gid))
		goto ok;
	if (ptrace_has_cap(tcred->user_ns, mode))
		goto ok;
	rcu_read_unlock();
	return -EPERM;
ok:
	rcu_read_unlock();
	smp_rmb();
	if (task->mm)
		dumpable = get_dumpable(task->mm);
	rcu_read_lock();
	if (!dumpable && !ptrace_has_cap(__task_cred(task)->user_ns, mode)) {
		rcu_read_unlock();
		return -EPERM;
	}
	rcu_read_unlock();

	return security_ptrace_access_check(task, mode);
}


    inline void pad(size_t bytes) {
      while (bytes-- > 0) writeU8(0);
    }


Datum ExecEvalExprSwitchContext ( ExprState * expression , ExprContext * econtext , bool * isNull , ExprDoneCond * isDone ) {
 Datum retDatum ;
 MemoryContext oldContext ;
 oldContext = MemoryContextSwitchTo ( econtext -> ecxt_per_tuple_memory ) ;
 retDatum = ExecEvalExpr ( expression , econtext , isNull , isDone ) ;
 MemoryContextSwitchTo ( oldContext ) ;
 return retDatum ;
 }


size_t TLSInStream::overrun(size_t itemSize, size_t nItems, bool wait)
{
  if (itemSize > bufSize)
    throw Exception("TLSInStream overrun: max itemSize exceeded");

  if (end - ptr != 0)
    memmove(start, ptr, end - ptr);

  offset += ptr - start;
  end -= ptr - start;
  ptr = start;

  while (end < start + itemSize) {
    size_t n = readTLS((U8*) end, start + bufSize - end, wait);
    if (!wait && n == 0)
      return 0;
    end += n;
  }

  if (itemSize * nItems > (size_t)(end - ptr))
    nItems = (end - ptr) / itemSize;

  return nItems;
}


size_t TLSInStream::pos()
{
  return offset + ptr - start;
}


void visit_start_struct(Visitor *v, void **obj, const char *kind, const char *name, size_t size, Error **errp) { if (!error_is_set(errp)) { v->start_struct(v, obj, kind, name, size, errp); } }


aio_ctx_finalize(GSource *source) { AioContext *ctx = (AioContext *) source; thread_pool_free(ctx->thread_pool); aio_set_event_notifier(ctx, &ctx->notifier, NULL); event_notifier_cleanup(&ctx->notifier); rfifolock_destroy(&ctx->lock); qemu_mutex_destroy(&ctx->bh_lock); timerlistgroup_deinit(&ctx->tlg);


my_send(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t len)
{
	long		size, sent;
    int         n;

	size = len;
	while (size) {
		n = php_pollfd_for_ms(s, POLLOUT, ftp->timeout_sec * 1000);

		if (n < 1) {

#if !defined(PHP_WIN32) && !(defined(NETWARE) && defined(USE_WINSOCK))
			if (n == 0) {
				errno = ETIMEDOUT;
			}
#endif
			return -1;
		}

#if HAVE_OPENSSL_EXT
		if (ftp->use_ssl && ftp->fd == s && ftp->ssl_active) {
			sent = SSL_write(ftp->ssl_handle, buf, size);
		} else if (ftp->use_ssl && ftp->fd != s && ftp->use_ssl_for_data && ftp->data->ssl_active) {
			sent = SSL_write(ftp->data->ssl_handle, buf, size);
		} else {
#endif
			sent = send(s, buf, size, 0);
#if HAVE_OPENSSL_EXT
		}
#endif
		if (sent == -1) {
			return -1;
		}

		buf = (char*) buf + sent;
		size -= sent;
	}

	return len;
}


static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, AVStream *vstream, int64_t max_pos) { unsigned int arraylen = 0, timeslen = 0, fileposlen = 0, i; double num_val; char str_val[256]; int64_t *times = NULL; int64_t *filepositions = NULL; int ret = AVERROR(ENOSYS); int64_t initial_pos = avio_tell(ioc); AVDictionaryEntry *creator = av_dict_get(s->metadata, "metadatacreator", NULL, 0); if (creator && !strcmp(creator->value, "MEGA")) { /* Files with this metadatacreator tag seem to have filepositions * pointing at the 4 trailer bytes of the previous packet, * which isn't the norm (nor what we expect here, nor what * jwplayer + lighttpd expect, nor what flvtool2 produces). * Just ignore the index in this case, instead of risking trying * to adjust it to something that might or might not work. */ return 0; } while (avio_tell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) { int64_t* current_array; // Expect array object in context if (avio_r8(ioc) != AMF_DATA_TYPE_ARRAY) break; arraylen = avio_rb32(ioc); /* * Expect only 'times' or 'filepositions' sub-arrays in other case refuse to use such metadata * for indexing */ if (!strcmp(KEYFRAMES_TIMESTAMP_TAG, str_val) && !times) { if (!(times = av_mallocz(sizeof(*times) * arraylen))) { ret = AVERROR(ENOMEM); goto finish; } timeslen = arraylen; current_array = times; } else if (!strcmp(KEYFRAMES_BYTEOFFSET_TAG, str_val) && !filepositions) { if (!(filepositions = av_mallocz(sizeof(*filepositions) * arraylen))) { ret = AVERROR(ENOMEM); goto finish; } fileposlen = arraylen; current_array = filepositions; } else // unexpected metatag inside keyframes, will not use such metadata for indexing break; for (i = 0; i < arraylen && avio_tell(ioc) < max_pos - 1; i++) { if (avio_r8(ioc) != AMF_DATA_TYPE_NUMBER) goto finish; num_val = av_int2dbl(avio_rb64(ioc)); current_array[i] = num_val; } if (times && filepositions) { // All done, exiting at a position allowing amf_parse_object // to finish parsing the object ret = 0; break; } } if (timeslen == fileposlen) for(i = 0; i < arraylen; i++) av_add_index_entry(vstream, filepositions[i], times[i]*1000, 0, 0, AVINDEX_KEYFRAME); else av_log(s, AV_LOG_WARNING, "Invalid keyframes object, skipping.\n"); finish: av_freep(&times); av_freep(&filepositions); // If we got unexpected data, but successfully reset back to // the start pos, the caller can continue parsing if (ret < 0 && avio_seek(ioc, initial_pos, SEEK_SET) > 0) return 0; return ret; }


ftp_pasv(ftpbuf_t *ftp, int pasv)
{
	char			*ptr;
	union ipbox		ipbox;
	unsigned long		b[6];
	socklen_t			n;
	struct sockaddr *sa;
	struct sockaddr_in *sin;

	if (ftp == NULL) {
		return 0;
	}
	if (pasv && ftp->pasv == 2) {
		return 1;
	}
	ftp->pasv = 0;
	if (!pasv) {
		return 1;
	}
	n = sizeof(ftp->pasvaddr);
	memset(&ftp->pasvaddr, 0, n);
	sa = (struct sockaddr *) &ftp->pasvaddr;

#if HAVE_IPV6
	if (getpeername(ftp->fd, sa, &n) < 0) {
		return 0;
	}
	if (sa->sa_family == AF_INET6) {
		struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sa;
		char *endptr, delimiter;

		/* try EPSV first */
		if (!ftp_putcmd(ftp, "EPSV", NULL)) {
			return 0;
		}
		if (!ftp_getresp(ftp)) {
			return 0;
		}
		if (ftp->resp == 229) {
			/* parse out the port */
			for (ptr = ftp->inbuf; *ptr && *ptr != '('; ptr++);
			if (!*ptr) {
				return 0;
			}
			delimiter = *++ptr;
			for (n = 0; *ptr && n < 3; ptr++) {
				if (*ptr == delimiter) {
					n++;
				}
			}

			sin6->sin6_port = htons((unsigned short) strtoul(ptr, &endptr, 10));
			if (ptr == endptr || *endptr != delimiter) {
				return 0;
			}
			ftp->pasv = 2;
			return 1;
		}
	}

	/* fall back to PASV */
#endif

	if (!ftp_putcmd(ftp, "PASV", NULL)) {
		return 0;
	}
	if (!ftp_getresp(ftp) || ftp->resp != 227) {
		return 0;
	}
	/* parse out the IP and port */
	for (ptr = ftp->inbuf; *ptr && !isdigit(*ptr); ptr++);
	n = sscanf(ptr, "%lu,%lu,%lu,%lu,%lu,%lu", &b[0], &b[1], &b[2], &b[3], &b[4], &b[5]);
	if (n != 6) {
		return 0;
	}
	for (n = 0; n < 6; n++) {
		ipbox.c[n] = (unsigned char) b[n];
	}
	sin = (struct sockaddr_in *) sa;
	sin->sin_family = AF_INET;
	sin->sin_addr = ipbox.ia[0];
	sin->sin_port = ipbox.s[2];

	ftp->pasv = 2;

	return 1;
}


ObfuscatedPasswd::ObfuscatedPasswd(const PlainPasswd& plainPwd) : CharArray(8), length(8) {
  int l = strlen(plainPwd.buf), i;
  for (i=0; i<8; i++)
    buf[i] = i<l ? plainPwd.buf[i] : 0;
  deskey(d3desObfuscationKey, EN0);
  des((rdr::U8*)buf, (rdr::U8*)buf);
}


static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock,
		struct msghdr *msg, size_t size, int flags)
{
	struct sock *sk = sock->sk;
	struct ipx_sock *ipxs = ipx_sk(sk);
	struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)msg->msg_name;
	struct ipxhdr *ipx = NULL;
	struct sk_buff *skb;
	int copied, rc;

	lock_sock(sk);
	/* put the autobinding in */
	if (!ipxs->port) {
		struct sockaddr_ipx uaddr;

		uaddr.sipx_port		= 0;
		uaddr.sipx_network 	= 0;

#ifdef CONFIG_IPX_INTERN
		rc = -ENETDOWN;
		if (!ipxs->intrfc)
			goto out; /* Someone zonked the iface */
		memcpy(uaddr.sipx_node, ipxs->intrfc->if_node, IPX_NODE_LEN);
#endif	/* CONFIG_IPX_INTERN */

		rc = __ipx_bind(sock, (struct sockaddr *)&uaddr,
			      sizeof(struct sockaddr_ipx));
		if (rc)
			goto out;
	}

	rc = -ENOTCONN;
	if (sock_flag(sk, SOCK_ZAPPED))
		goto out;

	skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
				flags & MSG_DONTWAIT, &rc);
	if (!skb)
		goto out;

	ipx 	= ipx_hdr(skb);
	copied 	= ntohs(ipx->ipx_pktsize) - sizeof(struct ipxhdr);
	if (copied > size) {
		copied = size;
		msg->msg_flags |= MSG_TRUNC;
	}

	rc = skb_copy_datagram_iovec(skb, sizeof(struct ipxhdr), msg->msg_iov,
				     copied);
	if (rc)
		goto out_free;
	if (skb->tstamp.tv64)
		sk->sk_stamp = skb->tstamp;

	msg->msg_namelen = sizeof(*sipx);

	if (sipx) {
		sipx->sipx_family	= AF_IPX;
		sipx->sipx_port		= ipx->ipx_source.sock;
		memcpy(sipx->sipx_node, ipx->ipx_source.node, IPX_NODE_LEN);
		sipx->sipx_network	= IPX_SKB_CB(skb)->ipx_source_net;
		sipx->sipx_type 	= ipx->ipx_type;
		sipx->sipx_zero		= 0;
	}
	rc = copied;

out_free:
	skb_free_datagram(sk, skb);
out:
	release_sock(sk);
	return rc;
}


static void test_io_channel_ipv4_fd(void) { QIOChannel *ioc; int fd = -1; fd = socket(AF_INET, SOCK_STREAM, 0); g_assert_cmpint(fd, >, -1); ioc = qio_channel_new_fd(fd, &error_abort); g_assert_cmpstr(object_get_typename(OBJECT(ioc)), ==, TYPE_QIO_CHANNEL_SOCKET); object_unref(OBJECT(ioc));


ObfuscatedPasswd::ObfuscatedPasswd(int len) : CharArray(len), length(len) {
}


static void write_slice_end ( MpegEncContext * s ) {
 if ( CONFIG_MPEG4_ENCODER && s -> codec_id == AV_CODEC_ID_MPEG4 ) {
 if ( s -> partitioned_frame ) {
 ff_mpeg4_merge_partitions ( s ) ;
 }
 ff_mpeg4_stuffing ( & s -> pb ) ;
 }
 else if ( CONFIG_MJPEG_ENCODER && s -> out_format == FMT_MJPEG ) {
 ff_mjpeg_encode_stuffing ( & s -> pb ) ;
 }
 avpriv_align_put_bits ( & s -> pb ) ;
 flush_put_bits ( & s -> pb ) ;
 if ( ( s -> flags & CODEC_FLAG_PASS1 ) && ! s -> partitioned_frame ) s -> misc_bits += get_bits_diff ( s ) ;
 }


static int qcow_write(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors) { Coroutine *co; AioContext *aio_context = bdrv_get_aio_context(bs); QcowWriteCo data = { .bs = bs, .sector_num = sector_num, .buf = buf, .nb_sectors = nb_sectors, .ret = -EINPROGRESS, }; co = qemu_coroutine_create(qcow_write_co_entry); qemu_coroutine_enter(co, &data); while (data.ret == -EINPROGRESS) { aio_poll(aio_context, true); } return data.ret; }


size_t DummyOutStream::length()
{
  flush();
  return offset;
}


static void v9fs_readdir(void *opaque) { int32_t fid; V9fsFidState *fidp; ssize_t retval = 0; size_t offset = 7; int64_t initial_offset; int32_t count, max_count; V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; pdu_unmarshal(pdu, offset, "dqd", &fid, &initial_offset, &max_count); trace_v9fs_readdir(pdu->tag, pdu->id, fid, initial_offset, max_count); fidp = get_fid(pdu, fid); if (fidp == NULL) { retval = -EINVAL; goto out_nofid; } if (!fidp->fs.dir) { retval = -EINVAL; goto out; } if (initial_offset == 0) { v9fs_co_rewinddir(pdu, fidp); } else { v9fs_co_seekdir(pdu, fidp, initial_offset); } count = v9fs_do_readdir(pdu, fidp, max_count); if (count < 0) { retval = count; goto out; } retval = offset; retval += pdu_marshal(pdu, offset, "d", count); retval += count; out: put_fid(pdu, fidp); out_nofid: complete_pdu(s, pdu, retval); }


static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
			  struct msghdr *msg, size_t len, int flags)
{
	struct sock *sk = sock->sk;
	struct sk_buff *skb;
	int copied, err;
	struct sockaddr_ll *sll;
	int vnet_hdr_len = 0;

	err = -EINVAL;
	if (flags & ~(MSG_PEEK|MSG_DONTWAIT|MSG_TRUNC|MSG_CMSG_COMPAT|MSG_ERRQUEUE))
		goto out;

#if 0
	/* What error should we return now? EUNATTACH? */
	if (pkt_sk(sk)->ifindex < 0)
		return -ENODEV;
#endif

	if (flags & MSG_ERRQUEUE) {
		err = sock_recv_errqueue(sk, msg, len,
					 SOL_PACKET, PACKET_TX_TIMESTAMP);
		goto out;
	}

	/*
	 *	Call the generic datagram receiver. This handles all sorts
	 *	of horrible races and re-entrancy so we can forget about it
	 *	in the protocol layers.
	 *
	 *	Now it will return ENETDOWN, if device have just gone down,
	 *	but then it will block.
	 */

	skb = skb_recv_datagram(sk, flags, flags & MSG_DONTWAIT, &err);

	/*
	 *	An error occurred so return it. Because skb_recv_datagram()
	 *	handles the blocking we don't see and worry about blocking
	 *	retries.
	 */

	if (skb == NULL)
		goto out;

	if (pkt_sk(sk)->has_vnet_hdr) {
		struct virtio_net_hdr vnet_hdr = { 0 };

		err = -EINVAL;
		vnet_hdr_len = sizeof(vnet_hdr);
		if (len < vnet_hdr_len)
			goto out_free;

		len -= vnet_hdr_len;

		if (skb_is_gso(skb)) {
			struct skb_shared_info *sinfo = skb_shinfo(skb);

			/* This is a hint as to how much should be linear. */
			vnet_hdr.hdr_len = skb_headlen(skb);
			vnet_hdr.gso_size = sinfo->gso_size;
			if (sinfo->gso_type & SKB_GSO_TCPV4)
				vnet_hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
			else if (sinfo->gso_type & SKB_GSO_TCPV6)
				vnet_hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
			else if (sinfo->gso_type & SKB_GSO_UDP)
				vnet_hdr.gso_type = VIRTIO_NET_HDR_GSO_UDP;
			else if (sinfo->gso_type & SKB_GSO_FCOE)
				goto out_free;
			else
				BUG();
			if (sinfo->gso_type & SKB_GSO_TCP_ECN)
				vnet_hdr.gso_type |= VIRTIO_NET_HDR_GSO_ECN;
		} else
			vnet_hdr.gso_type = VIRTIO_NET_HDR_GSO_NONE;

		if (skb->ip_summed == CHECKSUM_PARTIAL) {
			vnet_hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
			vnet_hdr.csum_start = skb_checksum_start_offset(skb);
			vnet_hdr.csum_offset = skb->csum_offset;
		} else if (skb->ip_summed == CHECKSUM_UNNECESSARY) {
			vnet_hdr.flags = VIRTIO_NET_HDR_F_DATA_VALID;
		} /* else everything is zero */

		err = memcpy_toiovec(msg->msg_iov, (void *)&vnet_hdr,
				     vnet_hdr_len);
		if (err < 0)
			goto out_free;
	}

	/*
	 *	If the address length field is there to be filled in, we fill
	 *	it in now.
	 */

	sll = &PACKET_SKB_CB(skb)->sa.ll;
	if (sock->type == SOCK_PACKET)
		msg->msg_namelen = sizeof(struct sockaddr_pkt);
	else
		msg->msg_namelen = sll->sll_halen + offsetof(struct sockaddr_ll, sll_addr);

	/*
	 *	You lose any data beyond the buffer you gave. If it worries a
	 *	user program they can ask the device for its MTU anyway.
	 */

	copied = skb->len;
	if (copied > len) {
		copied = len;
		msg->msg_flags |= MSG_TRUNC;
	}

	err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
	if (err)
		goto out_free;

	sock_recv_ts_and_drops(msg, sk, skb);

	if (msg->msg_name)
		memcpy(msg->msg_name, &PACKET_SKB_CB(skb)->sa,
		       msg->msg_namelen);

	if (pkt_sk(sk)->auxdata) {
		struct tpacket_auxdata aux;

		aux.tp_status = TP_STATUS_USER;
		if (skb->ip_summed == CHECKSUM_PARTIAL)
			aux.tp_status |= TP_STATUS_CSUMNOTREADY;
		aux.tp_len = PACKET_SKB_CB(skb)->origlen;
		aux.tp_snaplen = skb->len;
		aux.tp_mac = 0;
		aux.tp_net = skb_network_offset(skb);
		if (vlan_tx_tag_present(skb)) {
			aux.tp_vlan_tci = vlan_tx_tag_get(skb);
			aux.tp_status |= TP_STATUS_VLAN_VALID;
		} else {
			aux.tp_vlan_tci = 0;
		}
		aux.tp_padding = 0;
		put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(aux), &aux);
	}

	/*
	 *	Free or return the buffer as appropriate. Again this
	 *	hides all the races and re-entrancy issues from us.
	 */
	err = vnet_hdr_len + ((flags&MSG_TRUNC) ? skb->len : copied);

out_free:
	skb_free_datagram(sk, skb);
out:
	return err;
}


static int strtoint_clipped ( const char * const str , int min , int max ) {
 int r = strtoint ( str ) ;
 if ( r == - 1 ) return r ;
 else if ( r < min ) return min ;
 else if ( r > max ) return max ;
 else return r ;
 }


int mgs_hook_pre_config ( apr_pool_t * pconf , apr_pool_t * plog , apr_pool_t * ptemp __attribute__ ( ( unused ) ) ) {
 # if MOD_GNUTLS_DEBUG apr_file_open ( & debug_log_fp , "/tmp/gnutls_debug" , APR_APPEND | APR_WRITE | APR_CREATE , APR_OS_DEFAULT , pconf ) ;
 _gnutls_log ( debug_log_fp , "%s: %d\n" , __func__ , __LINE__ ) ;
 gnutls_global_set_log_level ( 9 ) ;
 gnutls_global_set_log_function ( gnutls_debug_log_all ) ;
 _gnutls_log ( debug_log_fp , "gnutls: %s\n" , gnutls_check_version ( NULL ) ) ;
 # endif int ret ;
 if ( gnutls_check_version ( LIBGNUTLS_VERSION ) == NULL ) {
 ap_log_perror ( APLOG_MARK , APLOG_EMERG , 0 , plog , "gnutls_check_version() failed. Required: " "gnutls-%s Found: gnutls-%s" , LIBGNUTLS_VERSION , gnutls_check_version ( NULL ) ) ;
 return DONE ;
 }
 ret = gnutls_global_init ( ) ;
 if ( ret < 0 ) {
 ap_log_perror ( APLOG_MARK , APLOG_EMERG , 0 , plog , "gnutls_global_init: %s" , gnutls_strerror ( ret ) ) ;
 return DONE ;
 }
 ret = gnutls_session_ticket_key_generate ( & session_ticket_key ) ;
 if ( ret < 0 ) {
 ap_log_perror ( APLOG_MARK , APLOG_EMERG , 0 , plog , "gnutls_session_ticket_key_generate: %s" , gnutls_strerror ( ret ) ) ;
 return DONE ;
 }
 AP_OPTIONAL_HOOK ( status_hook , mgs_status_hook , NULL , NULL , APR_HOOK_MIDDLE ) ;
 apr_pool_cleanup_register ( pconf , NULL , mgs_cleanup_pre_config , apr_pool_cleanup_null ) ;
 return OK ;
 }


static void coroutine_fn aio_read_response(void *opaque) { SheepdogObjRsp rsp; BDRVSheepdogState *s = opaque; int fd = s->fd; int ret; AIOReq *aio_req = NULL; SheepdogAIOCB *acb; uint64_t idx; /* read a header */ ret = qemu_co_recv(fd, &rsp, sizeof(rsp)); if (ret != sizeof(rsp)) { error_report("failed to get the header, %s", strerror(errno)); goto err; } /* find the right aio_req from the inflight aio list */ QLIST_FOREACH(aio_req, &s->inflight_aio_head, aio_siblings) { if (aio_req->id == rsp.id) { break; } } if (!aio_req) { error_report("cannot find aio_req %x", rsp.id); goto err; } acb = aio_req->aiocb; switch (acb->aiocb_type) { case AIOCB_WRITE_UDATA: /* this coroutine context is no longer suitable for co_recv * because we may send data to update vdi objects */ s->co_recv = NULL; if (!is_data_obj(aio_req->oid)) { break; } idx = data_oid_to_idx(aio_req->oid); if (s->inode.data_vdi_id[idx] != s->inode.vdi_id) { /* * If the object is newly created one, we need to update * the vdi object (metadata object). min_dirty_data_idx * and max_dirty_data_idx are changed to include updated * index between them. */ if (rsp.result == SD_RES_SUCCESS) { s->inode.data_vdi_id[idx] = s->inode.vdi_id; s->max_dirty_data_idx = MAX(idx, s->max_dirty_data_idx); s->min_dirty_data_idx = MIN(idx, s->min_dirty_data_idx); } /* * Some requests may be blocked because simultaneous * create requests are not allowed, so we search the * pending requests here. */ send_pending_req(s, aio_req->oid); } break; case AIOCB_READ_UDATA: ret = qemu_co_recvv(fd, acb->qiov->iov, acb->qiov->niov, aio_req->iov_offset, rsp.data_length); if (ret != rsp.data_length) { error_report("failed to get the data, %s", strerror(errno)); goto err; } break; case AIOCB_FLUSH_CACHE: if (rsp.result == SD_RES_INVALID_PARMS) { DPRINTF("disable cache since the server doesn't support it\n"); s->cache_flags = SD_FLAG_CMD_DIRECT; rsp.result = SD_RES_SUCCESS; } break; case AIOCB_DISCARD_OBJ: switch (rsp.result) { case SD_RES_INVALID_PARMS: error_report("sheep(%s) doesn't support discard command", s->host_spec); rsp.result = SD_RES_SUCCESS; s->discard_supported = false; break; case SD_RES_SUCCESS: idx = data_oid_to_idx(aio_req->oid); s->inode.data_vdi_id[idx] = 0; break; default: break; } } switch (rsp.result) { case SD_RES_SUCCESS: break; case SD_RES_READONLY: if (s->inode.vdi_id == oid_to_vid(aio_req->oid)) { ret = reload_inode(s, 0, ""); if (ret < 0) { goto err; } } if (is_data_obj(aio_req->oid)) { aio_req->oid = vid_to_data_oid(s->inode.vdi_id, data_oid_to_idx(aio_req->oid)); } else { aio_req->oid = vid_to_vdi_oid(s->inode.vdi_id); } resend_aioreq(s, aio_req); goto out; default: acb->ret = -EIO; error_report("%s", sd_strerror(rsp.result)); break; } free_aio_req(s, aio_req); if (!acb->nr_pending) { /* * We've finished all requests which belong to the AIOCB, so * we can switch back to sd_co_readv/writev now. */ acb->aio_done_func(acb); } out: s->co_recv = NULL; return; err: s->co_recv = NULL; reconnect_to_sdog(opaque); }


uint64_t helper_mulldo(CPUPPCState *env, uint64_t arg1, uint64_t arg2) { int64_t th; uint64_t tl; muls64(&tl, (uint64_t *)&th, arg1, arg2); /* If th != 0 && th != -1, then we had an overflow */ if (likely((uint64_t)(th + 1) <= 1)) { env->ov = 0; } else { env->so = env->ov = 1; } return (int64_t)tl; }


  void combine_list(String & res, const StringList & in)
  {
    res.clear();
    StringListEnumeration els = in.elements_obj();
    const char * s = 0;
    while ( (s = els.next()) != 0)
    {
      for (; *s; ++s) {
        if (*s == ':')
          res.append('\\');
        res.append(*s);
      }
      res.append(':');
    }
    if (!res.empty() && res.back() == ':') res.pop_back();
  }


  char * unescape(char * dest, const char * src)
  {
    while (*src) {
      if (*src == '\\') {
	++src;
	switch (*src) {
	case 'n': *dest = '\n'; break;
	case 'r': *dest = '\r'; break;
	case 't': *dest = '\t'; break;
	case 'f': *dest = '\f'; break;
	case 'v': *dest = '\v'; break;
	default: *dest = *src;
	}
      } else {
	*dest = *src;
      }
      ++src;
      ++dest;
    }
    *dest = '\0';
    return dest;
  }


IN_PROC_BROWSER_TEST_F ( FastUnloadTest , BrowserListForceCloseNoUnloadListenersWithFastUnload ) {
 NavigateToDataURL ( NOLISTENERS_HTML , "nolisteners" ) ;
 content : : WindowedNotificationObserver window_observer ( chrome : : NOTIFICATION_BROWSER_CLOSED , content : : NotificationService : : AllSources ( ) ) ;
 UnloadResults unload_results ;
 BrowserList : : CloseAllBrowsersWithProfile ( browser ( ) -> profile ( ) , base : : Bind ( & UnloadResults : : AddSuccess , base : : Unretained ( & unload_results ) ) , base : : Bind ( & UnloadResults : : AddAbort , base : : Unretained ( & unload_results ) ) , true ) ;
 window_observer . Wait ( ) ;
 EXPECT_EQ ( 1 , unload_results . get_successes ( ) ) ;
 EXPECT_EQ ( 0 , unload_results . get_aborts ( ) ) ;
 }


TSReturnCode TSMBufferDestroy ( TSMBuffer bufp ) {
 if ( ! isWriteable ( bufp ) ) {
 return TS_ERROR ;
 }
 sdk_assert ( sdk_sanity_check_mbuffer ( bufp ) == TS_SUCCESS ) ;
 HdrHeapSDKHandle * sdk_heap = ( HdrHeapSDKHandle * ) bufp ;
 sdk_heap -> m_heap -> destroy ( ) ;
 delete sdk_heap ;
 return TS_SUCCESS ;
 }


static int oss_init_in (HWVoiceIn *hw, audsettings_t *as) { OSSVoiceIn *oss = (OSSVoiceIn *) hw; struct oss_params req, obt; int endianness; int err; int fd; audfmt_e effective_fmt; audsettings_t obt_as; oss->fd = -1; req.fmt = aud_to_ossfmt (as->fmt); req.freq = as->freq; req.nchannels = as->nchannels; req.fragsize = conf.fragsize; req.nfrags = conf.nfrags; if (oss_open (1, &req, &obt, &fd)) { return -1; } err = oss_to_audfmt (obt.fmt, &effective_fmt, &endianness); if (err) { oss_anal_close (&fd); return -1; } obt_as.freq = obt.freq; obt_as.nchannels = obt.nchannels; obt_as.fmt = effective_fmt; obt_as.endianness = endianness; audio_pcm_init_info (&hw->info, &obt_as); oss->nfrags = obt.nfrags; oss->fragsize = obt.fragsize; if (obt.nfrags * obt.fragsize & hw->info.align) { dolog ("warning: Misaligned ADC buffer, size %d, alignment %d\n", obt.nfrags * obt.fragsize, hw->info.align + 1); } hw->samples = (obt.nfrags * obt.fragsize) >> hw->info.shift; oss->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift); if (!oss->pcm_buf) { dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\n", hw->samples, 1 << hw->info.shift); oss_anal_close (&fd); return -1; } oss->fd = fd; return 0; }


std::string get_wml_location(const std::string &filename, const std::string &current_dir)
{
	DBG_FS << "Looking for '" << filename << "'." << std::endl;

	assert(game_config::path.empty() == false);

	std::string result;

	if (filename.empty()) {
		LOG_FS << "  invalid filename" << std::endl;
		return result;
	}

	if (filename.find("..") != std::string::npos) {
		ERR_FS << "Illegal path '" << filename << "' (\"..\" not allowed)." << std::endl;
		return result;
	}

	bool already_found = false;

	if (filename[0] == '~')
	{
		// If the filename starts with '~', look in the user data directory.
		result = get_user_data_dir() + "/data/" + filename.substr(1);
		DBG_FS << "  trying '" << result << "'" << std::endl;

		already_found = file_exists(result) || is_directory(result);
	}
	else if (filename.size() >= 2 && filename[0] == '.' && filename[1] == '/')
	{
		// If the filename begins with a "./", look in the same directory
		// as the file currently being preprocessed.

		if (!current_dir.empty())
		{
			result = current_dir;
		}
		else
		{
			result = game_config::path;
		}

		result += filename.substr(2);
	}
	else if (!game_config::path.empty())
		result = game_config::path + "/data/" + filename;

	DBG_FS << "  trying '" << result << "'" << std::endl;

	if (result.empty() ||
	    (!already_found && !file_exists(result) && !is_directory(result)))
	{
		DBG_FS << "  not found" << std::endl;
		result.clear();
	}
	else
		DBG_FS << "  found: '" << result << "'" << std::endl;

	return result;
}


static void pvfc_fmt_release_num ( gchar * result , guint32 release_nr ) {
 g_snprintf ( result , ITEM_LABEL_LENGTH , "%d (%d.%d.%d)" , release_nr , release_nr / 10000 , ( release_nr % 10000 ) / 100 , ( release_nr % 10000 ) % 100 ) ;
 }


static void xps_parse_path_figure ( fz_context * doc , fz_path * path , fz_xml * root , int stroking ) {
 fz_xml * node ;
 char * is_closed_att ;
 char * start_point_att ;
 char * is_filled_att ;
 int is_closed = 0 ;
 int is_filled = 1 ;
 float start_x = 0 ;
 float start_y = 0 ;
 int skipped_stroke = 0 ;
 is_closed_att = fz_xml_att ( root , "IsClosed" ) ;
 start_point_att = fz_xml_att ( root , "StartPoint" ) ;
 is_filled_att = fz_xml_att ( root , "IsFilled" ) ;
 if ( is_closed_att ) is_closed = ! strcmp ( is_closed_att , "true" ) ;
 if ( is_filled_att ) is_filled = ! strcmp ( is_filled_att , "true" ) ;
 if ( start_point_att ) xps_parse_point ( start_point_att , & start_x , & start_y ) ;
 if ( ! stroking && ! is_filled ) return ;
 fz_moveto ( doc , path , start_x , start_y ) ;
 for ( node = fz_xml_down ( root ) ;
 node ;
 node = fz_xml_next ( node ) ) {
 if ( ! strcmp ( fz_xml_tag ( node ) , "ArcSegment" ) ) xps_parse_arc_segment ( doc , path , node , stroking , & skipped_stroke ) ;
 if ( ! strcmp ( fz_xml_tag ( node ) , "PolyBezierSegment" ) ) xps_parse_poly_bezier_segment ( doc , path , node , stroking , & skipped_stroke ) ;
 if ( ! strcmp ( fz_xml_tag ( node ) , "PolyLineSegment" ) ) xps_parse_poly_line_segment ( doc , path , node , stroking , & skipped_stroke ) ;
 if ( ! strcmp ( fz_xml_tag ( node ) , "PolyQuadraticBezierSegment" ) ) xps_parse_poly_quadratic_bezier_segment ( doc , path , node , stroking , & skipped_stroke ) ;
 }
 if ( is_closed ) {
 if ( stroking && skipped_stroke ) fz_lineto ( doc , path , start_x , start_y ) ;
 else fz_closepath ( doc , path ) ;
 }
 }


static int __vcpu_run(struct kvm_vcpu *vcpu)
{
	int r;
	struct kvm *kvm = vcpu->kvm;

	vcpu->srcu_idx = srcu_read_lock(&kvm->srcu);
	r = vapic_enter(vcpu);
	if (r) {
		srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx);
		return r;
	}

	r = 1;
	while (r > 0) {
		if (vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE &&
		    !vcpu->arch.apf.halted)
			r = vcpu_enter_guest(vcpu);
		else {
			srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx);
			kvm_vcpu_block(vcpu);
			vcpu->srcu_idx = srcu_read_lock(&kvm->srcu);
			if (kvm_check_request(KVM_REQ_UNHALT, vcpu)) {
				kvm_apic_accept_events(vcpu);
				switch(vcpu->arch.mp_state) {
				case KVM_MP_STATE_HALTED:
					vcpu->arch.pv.pv_unhalted = false;
					vcpu->arch.mp_state =
						KVM_MP_STATE_RUNNABLE;
				case KVM_MP_STATE_RUNNABLE:
					vcpu->arch.apf.halted = false;
					break;
				case KVM_MP_STATE_INIT_RECEIVED:
					break;
				default:
					r = -EINTR;
					break;
				}
			}
		}

		if (r <= 0)
			break;

		clear_bit(KVM_REQ_PENDING_TIMER, &vcpu->requests);
		if (kvm_cpu_has_pending_timer(vcpu))
			kvm_inject_pending_timer_irqs(vcpu);

		if (dm_request_for_irq_injection(vcpu)) {
			r = -EINTR;
			vcpu->run->exit_reason = KVM_EXIT_INTR;
			++vcpu->stat.request_irq_exits;
		}

		kvm_check_async_pf_completion(vcpu);

		if (signal_pending(current)) {
			r = -EINTR;
			vcpu->run->exit_reason = KVM_EXIT_INTR;
			++vcpu->stat.signal_exits;
		}
		if (need_resched()) {
			srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx);
			kvm_resched(vcpu);
			vcpu->srcu_idx = srcu_read_lock(&kvm->srcu);
		}
	}

	srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx);

	vapic_exit(vcpu);

	return r;
}


bool MemoryManager::validate_user_write(const Process& process, VirtualAddress vaddr) const
{
    auto* region = region_from_vaddr(process, vaddr);
    return region && region->is_writable();
}


bool MemoryManager::validate_user_write(const Process& process, VirtualAddress vaddr) const
{
    auto* region = user_region_from_vaddr(const_cast<Process&>(process), vaddr);
    return region && region->is_user_accessible() && region->is_writable();
}


static bool MR_primality_test(UnsignedBigInteger n, const Vector<UnsignedBigInteger, 256>& tests)
{
    // Written using Wikipedia:
    // https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test#Miller%E2%80%93Rabin_test
    ASSERT(!(n < 4));
    auto predecessor = n.minus({ 1 });
    auto d = predecessor;
    size_t r = 0;

    {
        auto div_result = d.divided_by(2);
        while (div_result.remainder == 0) {
            d = div_result.quotient;
            div_result = d.divided_by(2);
            ++r;
        }
    }
    if (r == 0) {
        // n - 1 is odd, so n was even. But there is only one even prime:
        return n == 2;
    }

    for (auto a : tests) {
        // Technically: ASSERT(2 <= a && a <= n - 2)
        ASSERT(a < n);
        auto x = ModularPower(a, d, n);
        if (x == 1 || x == predecessor)
            continue;
        bool skip_this_witness = false;
        // r − 1 iterations.
        for (size_t i = 0; i < r - 1; ++i) {
            x = ModularPower(x, 2, n);
            if (x == predecessor) {
                skip_this_witness = true;
                break;
            }
        }
        if (skip_this_witness)
            continue;
        return false; // "composite"
    }

    return true; // "probably prime"
}


TEST_F ( FullscreenControllerStateUnitTest , DISABLED_ToggleTabWhenPendingTab ) {
 if ( FullscreenControllerStateTest : : IsWindowFullscreenStateChangedReentrant ( ) ) return ;
 AddTab ( browser ( ) , GURL ( url : : kAboutBlankURL ) ) ;
 ASSERT_NO_FATAL_FAILURE ( TransitionToState ( STATE_TO_TAB_FULLSCREEN ) ) << GetAndClearDebugLog ( ) ;
 ASSERT_TRUE ( InvokeEvent ( TAB_FULLSCREEN_TRUE ) ) << GetAndClearDebugLog ( ) ;
 ASSERT_TRUE ( InvokeEvent ( TAB_FULLSCREEN_FALSE ) ) << GetAndClearDebugLog ( ) ;
 ASSERT_TRUE ( InvokeEvent ( WINDOW_CHANGE ) ) << GetAndClearDebugLog ( ) ;
 }


IN_PROC_BROWSER_TEST_F ( HttpsEngagementPageLoadMetricsBrowserTest , Navigate_Both_NonHtmlMainResource ) {
 StartHttpServer ( ) ;
 StartHttpsServer ( false ) ;
 NavigateTwiceInTabAndClose ( http_test_server_ -> GetURL ( "/circle.svg" ) , https_test_server_ -> GetURL ( "/circle.svg" ) ) ;
 histogram_tester_ . ExpectTotalCount ( internal : : kHttpEngagementHistogram , 1 ) ;
 histogram_tester_ . ExpectTotalCount ( internal : : kHttpsEngagementHistogram , 1 ) ;
 }


static void qbus_print(Monitor *mon, BusState *bus, int indent) { struct DeviceState *dev; qdev_printf("bus: %s\n", bus->name); indent += 2; qdev_printf("type %s\n", bus_type_names[bus->type]); LIST_FOREACH(dev, &bus->children, sibling) { qdev_print(mon, dev, indent); } }


static void mvc_fast_memset(CPUS390XState *env, uint32_t l, uint64_t dest, uint8_t byte) { S390CPU *cpu = s390_env_get_cpu(env); hwaddr dest_phys; hwaddr len = l; void *dest_p; uint64_t asc = env->psw.mask & PSW_MASK_ASC; int flags; if (mmu_translate(env, dest, 1, asc, &dest_phys, &flags)) { cpu_stb_data(env, dest, byte); cpu_abort(CPU(cpu), "should never reach here"); } dest_phys |= dest & ~TARGET_PAGE_MASK; dest_p = cpu_physical_memory_map(dest_phys, &len, 1); memset(dest_p, byte, len); cpu_physical_memory_unmap(dest_p, 1, len, len); }


static int dccp_error(struct net *net, struct nf_conn *tmpl,
		      struct sk_buff *skb, unsigned int dataoff,
		      enum ip_conntrack_info *ctinfo,
		      u_int8_t pf, unsigned int hooknum)
{
	struct dccp_hdr _dh, *dh;
	unsigned int dccp_len = skb->len - dataoff;
	unsigned int cscov;
	const char *msg;

	dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
	if (dh == NULL) {
		msg = "nf_ct_dccp: short packet ";
		goto out_invalid;
	}

	if (dh->dccph_doff * 4 < sizeof(struct dccp_hdr) ||
	    dh->dccph_doff * 4 > dccp_len) {
		msg = "nf_ct_dccp: truncated/malformed packet ";
		goto out_invalid;
	}

	cscov = dccp_len;
	if (dh->dccph_cscov) {
		cscov = (dh->dccph_cscov - 1) * 4;
		if (cscov > dccp_len) {
			msg = "nf_ct_dccp: bad checksum coverage ";
			goto out_invalid;
		}
	}

	if (net->ct.sysctl_checksum && hooknum == NF_INET_PRE_ROUTING &&
	    nf_checksum_partial(skb, hooknum, dataoff, cscov, IPPROTO_DCCP,
				pf)) {
		msg = "nf_ct_dccp: bad checksum ";
		goto out_invalid;
	}

	if (dh->dccph_type >= DCCP_PKT_INVALID) {
		msg = "nf_ct_dccp: reserved packet type ";
		goto out_invalid;
	}

	return NF_ACCEPT;

out_invalid:
	if (LOG_INVALID(net, IPPROTO_DCCP))
		nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
	return -NF_ACCEPT;
}


static void pxa2xx_rtc_swupdate ( PXA2xxRTCState * s ) {
 int64_t rt = qemu_get_clock_ms ( rtc_clock ) ;
 if ( s -> rtsr & ( 1 << 12 ) ) s -> last_swcr += ( rt - s -> last_sw ) / 10 ;
 s -> last_sw = rt ;
 }


static void code_gen_alloc(unsigned long tb_size) { #ifdef USE_STATIC_CODE_GEN_BUFFER code_gen_buffer = static_code_gen_buffer; code_gen_buffer_size = DEFAULT_CODE_GEN_BUFFER_SIZE; map_exec(code_gen_buffer, code_gen_buffer_size); #else code_gen_buffer_size = tb_size; if (code_gen_buffer_size == 0) { #if defined(CONFIG_USER_ONLY) /* in user mode, phys_ram_size is not meaningful */ code_gen_buffer_size = DEFAULT_CODE_GEN_BUFFER_SIZE; #else /* XXX: needs adjustments */ code_gen_buffer_size = (unsigned long)(ram_size / 4); #endif } if (code_gen_buffer_size < MIN_CODE_GEN_BUFFER_SIZE) code_gen_buffer_size = MIN_CODE_GEN_BUFFER_SIZE; /* The code gen buffer location may have constraints depending on the host cpu and OS */ #if defined(__linux__) { int flags; void *start = NULL; flags = MAP_PRIVATE | MAP_ANONYMOUS; #if defined(__x86_64__) flags |= MAP_32BIT; /* Cannot map more than that */ if (code_gen_buffer_size > (800 * 1024 * 1024)) code_gen_buffer_size = (800 * 1024 * 1024); #elif defined(__sparc_v9__) // Map the buffer below 2G, so we can use direct calls and branches flags |= MAP_FIXED; start = (void *) 0x60000000UL; if (code_gen_buffer_size > (512 * 1024 * 1024)) code_gen_buffer_size = (512 * 1024 * 1024); #elif defined(__arm__) /* Map the buffer below 32M, so we can use direct calls and branches */ flags |= MAP_FIXED; start = (void *) 0x01000000UL; if (code_gen_buffer_size > 16 * 1024 * 1024) code_gen_buffer_size = 16 * 1024 * 1024; #elif defined(__s390x__) /* Map the buffer so that we can use direct calls and branches. */ /* We have a +- 4GB range on the branches; leave some slop. */ if (code_gen_buffer_size > (3ul * 1024 * 1024 * 1024)) { code_gen_buffer_size = 3ul * 1024 * 1024 * 1024; } start = (void *)0x90000000UL; #endif code_gen_buffer = mmap(start, code_gen_buffer_size, PROT_WRITE | PROT_READ | PROT_EXEC, flags, -1, 0); if (code_gen_buffer == MAP_FAILED) { fprintf(stderr, "Could not allocate dynamic translator buffer\n"); exit(1); } } #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \ || defined(__DragonFly__) || defined(__OpenBSD__) { int flags; void *addr = NULL; flags = MAP_PRIVATE | MAP_ANONYMOUS; #if defined(__x86_64__) /* FreeBSD doesn't have MAP_32BIT, use MAP_FIXED and assume * 0x40000000 is free */ flags |= MAP_FIXED; addr = (void *)0x40000000; /* Cannot map more than that */ if (code_gen_buffer_size > (800 * 1024 * 1024)) code_gen_buffer_size = (800 * 1024 * 1024); #elif defined(__sparc_v9__) // Map the buffer below 2G, so we can use direct calls and branches flags |= MAP_FIXED; addr = (void *) 0x60000000UL; if (code_gen_buffer_size > (512 * 1024 * 1024)) { code_gen_buffer_size = (512 * 1024 * 1024); } #endif code_gen_buffer = mmap(addr, code_gen_buffer_size, PROT_WRITE | PROT_READ | PROT_EXEC, flags, -1, 0); if (code_gen_buffer == MAP_FAILED) { fprintf(stderr, "Could not allocate dynamic translator buffer\n"); exit(1); } } #else code_gen_buffer = qemu_malloc(code_gen_buffer_size); map_exec(code_gen_buffer, code_gen_buffer_size); #endif #endif /* !USE_STATIC_CODE_GEN_BUFFER */ map_exec(code_gen_prologue, sizeof(code_gen_prologue)); code_gen_buffer_max_size = code_gen_buffer_size - (TCG_MAX_OP_SIZE * OPC_MAX_SIZE); code_gen_max_blocks = code_gen_buffer_size / CODE_GEN_AVG_BLOCK_SIZE; tbs = qemu_malloc(code_gen_max_blocks * sizeof(TranslationBlock)); }


static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
		     unsigned int dataoff, unsigned int *timeouts)
{
	struct net *net = nf_ct_net(ct);
	struct dccp_net *dn;
	struct dccp_hdr _dh, *dh;
	const char *msg;
	u_int8_t state;

	dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
	BUG_ON(dh == NULL);

	state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
	switch (state) {
	default:
		dn = dccp_pernet(net);
		if (dn->dccp_loose == 0) {
			msg = "nf_ct_dccp: not picking up existing connection ";
			goto out_invalid;
		}
	case CT_DCCP_REQUEST:
		break;
	case CT_DCCP_INVALID:
		msg = "nf_ct_dccp: invalid state transition ";
		goto out_invalid;
	}

	ct->proto.dccp.role[IP_CT_DIR_ORIGINAL] = CT_DCCP_ROLE_CLIENT;
	ct->proto.dccp.role[IP_CT_DIR_REPLY] = CT_DCCP_ROLE_SERVER;
	ct->proto.dccp.state = CT_DCCP_NONE;
	ct->proto.dccp.last_pkt = DCCP_PKT_REQUEST;
	ct->proto.dccp.last_dir = IP_CT_DIR_ORIGINAL;
	ct->proto.dccp.handshake_seq = 0;
	return true;

out_invalid:
	if (LOG_INVALID(net, IPPROTO_DCCP))
		nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
			      NULL, "%s", msg);
	return false;
}


otError Commissioner::AddJoiner(const Mac::ExtAddress *aEui64, const char *aPskd, uint32_t aTimeout)
{
    otError error = OT_ERROR_NO_BUFS;

    VerifyOrExit(mState == OT_COMMISSIONER_STATE_ACTIVE, error = OT_ERROR_INVALID_STATE);

    VerifyOrExit(strlen(aPskd) <= Dtls::kPskMaxLength, error = OT_ERROR_INVALID_ARGS);
    RemoveJoiner(aEui64, 0); // remove immediately

    for (Joiner *joiner = &mJoiners[0]; joiner < OT_ARRAY_END(mJoiners); joiner++)
    {
        if (joiner->mValid)
        {
            continue;
        }

        if (aEui64 != NULL)
        {
            joiner->mEui64 = *aEui64;
            joiner->mAny   = false;
        }
        else
        {
            joiner->mAny = true;
        }

        (void)strlcpy(joiner->mPsk, aPskd, sizeof(joiner->mPsk));
        joiner->mValid          = true;
        joiner->mExpirationTime = TimerMilli::GetNow() + Time::SecToMsec(aTimeout);

        UpdateJoinerExpirationTimer();

        SendCommissionerSet();

        otLogInfoMeshCoP("Added Joiner (%s, %s)", (aEui64 != NULL) ? aEui64->ToString().AsCString() : "*", aPskd);

        ExitNow(error = OT_ERROR_NONE);
    }

exit:
    return error;
}


static inline void init_fs_pin(struct fs_pin *p, void (*kill)(struct fs_pin *))
{
	init_waitqueue_head(&p->wait);
	p->kill = kill;
}


static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
		       unsigned int dataoff, enum ip_conntrack_info ctinfo,
		       u_int8_t pf, unsigned int hooknum,
		       unsigned int *timeouts)
{
	struct net *net = nf_ct_net(ct);
	enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
	struct dccp_hdr _dh, *dh;
	u_int8_t type, old_state, new_state;
	enum ct_dccp_roles role;

	dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
	BUG_ON(dh == NULL);
	type = dh->dccph_type;

	if (type == DCCP_PKT_RESET &&
	    !test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) {
		/* Tear down connection immediately if only reply is a RESET */
		nf_ct_kill_acct(ct, ctinfo, skb);
		return NF_ACCEPT;
	}

	spin_lock_bh(&ct->lock);

	role = ct->proto.dccp.role[dir];
	old_state = ct->proto.dccp.state;
	new_state = dccp_state_table[role][type][old_state];

	switch (new_state) {
	case CT_DCCP_REQUEST:
		if (old_state == CT_DCCP_TIMEWAIT &&
		    role == CT_DCCP_ROLE_SERVER) {
			/* Reincarnation in the reverse direction: reopen and
			 * reverse client/server roles. */
			ct->proto.dccp.role[dir] = CT_DCCP_ROLE_CLIENT;
			ct->proto.dccp.role[!dir] = CT_DCCP_ROLE_SERVER;
		}
		break;
	case CT_DCCP_RESPOND:
		if (old_state == CT_DCCP_REQUEST)
			ct->proto.dccp.handshake_seq = dccp_hdr_seq(dh);
		break;
	case CT_DCCP_PARTOPEN:
		if (old_state == CT_DCCP_RESPOND &&
		    type == DCCP_PKT_ACK &&
		    dccp_ack_seq(dh) == ct->proto.dccp.handshake_seq)
			set_bit(IPS_ASSURED_BIT, &ct->status);
		break;
	case CT_DCCP_IGNORE:
		/*
		 * Connection tracking might be out of sync, so we ignore
		 * packets that might establish a new connection and resync
		 * if the server responds with a valid Response.
		 */
		if (ct->proto.dccp.last_dir == !dir &&
		    ct->proto.dccp.last_pkt == DCCP_PKT_REQUEST &&
		    type == DCCP_PKT_RESPONSE) {
			ct->proto.dccp.role[!dir] = CT_DCCP_ROLE_CLIENT;
			ct->proto.dccp.role[dir] = CT_DCCP_ROLE_SERVER;
			ct->proto.dccp.handshake_seq = dccp_hdr_seq(dh);
			new_state = CT_DCCP_RESPOND;
			break;
		}
		ct->proto.dccp.last_dir = dir;
		ct->proto.dccp.last_pkt = type;

		spin_unlock_bh(&ct->lock);
		if (LOG_INVALID(net, IPPROTO_DCCP))
			nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
				      "nf_ct_dccp: invalid packet ignored ");
		return NF_ACCEPT;
	case CT_DCCP_INVALID:
		spin_unlock_bh(&ct->lock);
		if (LOG_INVALID(net, IPPROTO_DCCP))
			nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
				      "nf_ct_dccp: invalid state transition ");
		return -NF_ACCEPT;
	}

	ct->proto.dccp.last_dir = dir;
	ct->proto.dccp.last_pkt = type;
	ct->proto.dccp.state = new_state;
	spin_unlock_bh(&ct->lock);

	if (new_state != old_state)
		nf_conntrack_event_cache(IPCT_PROTOINFO, ct);

	nf_ct_refresh_acct(ct, ctinfo, skb, timeouts[new_state]);

	return NF_ACCEPT;
}


static Asn1Generic * DecodeAsn1DerOctetString ( const unsigned char * buffer , uint32_t max_size , uint8_t depth , uint32_t * errcode ) {
 const unsigned char * d_ptr = buffer ;
 uint32_t length , numbytes ;
 Asn1Generic * a ;
 unsigned char c ;
 d_ptr ++ ;
 c = d_ptr [ 0 ] ;
 if ( ( c & ( 1 << 7 ) ) >> 7 == 0 ) {
 length = c ;
 d_ptr ++ ;
 }
 else {
 numbytes = c & 0x7f ;
 d_ptr ++ ;
 if ( DecodeAsn1BuildValue ( & d_ptr , & length , numbytes , errcode ) == - 1 ) {
 return NULL ;
 }
 }
 if ( length > max_size ) return NULL ;
 a = Asn1GenericNew ( ) ;
 if ( a == NULL ) return NULL ;
 a -> type = ASN1_OCTETSTRING ;
 a -> strlen = length ;
 a -> str = SCMalloc ( length + 1 ) ;
 if ( a -> str == NULL ) {
 SCFree ( a ) ;
 return NULL ;
 }
 memcpy ( a -> str , ( const char * ) d_ptr , length ) ;
 a -> str [ length ] = 0 ;
 d_ptr += length ;
 a -> length = ( d_ptr - buffer ) ;
 return a ;
 }


static void rd_release_device_space(struct rd_dev *rd_dev)
{
	u32 i, j, page_count = 0, sg_per_table;
	struct rd_dev_sg_table *sg_table;
	struct page *pg;
	struct scatterlist *sg;

	if (!rd_dev->sg_table_array || !rd_dev->sg_table_count)
		return;

	sg_table = rd_dev->sg_table_array;

	for (i = 0; i < rd_dev->sg_table_count; i++) {
		sg = sg_table[i].sg_table;
		sg_per_table = sg_table[i].rd_sg_count;

		for (j = 0; j < sg_per_table; j++) {
			pg = sg_page(&sg[j]);
			if (pg) {
				__free_page(pg);
				page_count++;
			}
		}

		kfree(sg);
	}

	pr_debug("CORE_RD[%u] - Released device space for Ramdisk"
		" Device ID: %u, pages %u in %u tables total bytes %lu\n",
		rd_dev->rd_host->rd_host_id, rd_dev->rd_dev_id, page_count,
		rd_dev->sg_table_count, (unsigned long)page_count * PAGE_SIZE);

	kfree(sg_table);
	rd_dev->sg_table_array = NULL;
	rd_dev->sg_table_count = 0;
}


Debug(const char *fmtstr,
      va_list args)
{
   /* Ignored */
#ifdef VMX86_DEBUG
   sLog(log_debug, "Debug callback invoked. \n");
#endif
}