idx
int64
func_before
string
Vulnerability Classification
string
vul
int64
func_after
string
patch
string
CWE ID
string
lines_before
string
lines_after
string
10,700
SmartScheduleTimer (int sig) { SmartScheduleTime += SmartScheduleInterval; }
DoS
0
SmartScheduleTimer (int sig) { SmartScheduleTime += SmartScheduleInterval; }
@@ -297,7 +297,7 @@ LockServer(void) FatalError("Could not create lock file in %s\n", tmp); (void) sprintf(pid_str, "%10ld\n", (long)getpid()); (void) write(lfd, pid_str, 11); - (void) chmod(tmp, 0444); + (void) fchmod(lfd, 0444); (void) close(lfd); /*
CWE-362
null
null
10,701
System(char *command) { int pid, p; void (*csig)(int); int status; if (!command) return 1; csig = signal(SIGCHLD, SIG_DFL); if (csig == SIG_ERR) { perror("signal"); return -1; } DebugF("System: `%s'\n", command); switch (pid = fork()) { case -1: /* error */ p = -1; case 0: /* child */ if (setgid(getgid()) == -1) _exit(127); if (setuid(getuid()) == -1) _exit(127); execl("/bin/sh", "sh", "-c", command, (char *)NULL); _exit(127); default: /* parent */ do { p = waitpid(pid, &status, 0); } while (p == -1 && errno == EINTR); } if (signal(SIGCHLD, csig) == SIG_ERR) { perror("signal"); return -1; } return p == -1 ? -1 : status; }
DoS
0
System(char *command) { int pid, p; void (*csig)(int); int status; if (!command) return 1; csig = signal(SIGCHLD, SIG_DFL); if (csig == SIG_ERR) { perror("signal"); return -1; } DebugF("System: `%s'\n", command); switch (pid = fork()) { case -1: /* error */ p = -1; case 0: /* child */ if (setgid(getgid()) == -1) _exit(127); if (setuid(getuid()) == -1) _exit(127); execl("/bin/sh", "sh", "-c", command, (char *)NULL); _exit(127); default: /* parent */ do { p = waitpid(pid, &status, 0); } while (p == -1 && errno == EINTR); } if (signal(SIGCHLD, csig) == SIG_ERR) { perror("signal"); return -1; } return p == -1 ? -1 : status; }
@@ -297,7 +297,7 @@ LockServer(void) FatalError("Could not create lock file in %s\n", tmp); (void) sprintf(pid_str, "%10ld\n", (long)getpid()); (void) write(lfd, pid_str, 11); - (void) chmod(tmp, 0444); + (void) fchmod(lfd, 0444); (void) close(lfd); /*
CWE-362
null
null
10,702
UnlockServer(void) { if (nolock) return; if (!StillLocking){ (void) unlink(LockFile); } }
DoS
0
UnlockServer(void) { if (nolock) return; if (!StillLocking){ (void) unlink(LockFile); } }
@@ -297,7 +297,7 @@ LockServer(void) FatalError("Could not create lock file in %s\n", tmp); (void) sprintf(pid_str, "%10ld\n", (long)getpid()); (void) write(lfd, pid_str, 11); - (void) chmod(tmp, 0444); + (void) fchmod(lfd, 0444); (void) close(lfd); /*
CWE-362
null
null
10,703
void UseMsg(void) { ErrorF("use: X [:<display>] [option]\n"); ErrorF("-a # default pointer acceleration (factor)\n"); ErrorF("-ac disable access control restrictions\n"); ErrorF("-audit int set audit trail level\n"); ErrorF("-auth file select authorization file\n"); ErrorF("-br create root window with black background\n"); ErrorF("+bs enable any backing store support\n"); ErrorF("-bs disable any backing store support\n"); ErrorF("-c turns off key-click\n"); ErrorF("c # key-click volume (0-100)\n"); ErrorF("-cc int default color visual class\n"); ErrorF("-nocursor disable the cursor\n"); ErrorF("-core generate core dump on fatal error\n"); ErrorF("-dpi int screen resolution in dots per inch\n"); #ifdef DPMSExtension ErrorF("-dpms disables VESA DPMS monitor control\n"); #endif ErrorF("-deferglyphs [none|all|16] defer loading of [no|all|16-bit] glyphs\n"); ErrorF("-f # bell base (0-100)\n"); ErrorF("-fc string cursor font\n"); ErrorF("-fn string default font name\n"); ErrorF("-fp string default font path\n"); ErrorF("-help prints message with these options\n"); ErrorF("-I ignore all remaining arguments\n"); #ifdef RLIMIT_DATA ErrorF("-ld int limit data space to N Kb\n"); #endif #ifdef RLIMIT_NOFILE ErrorF("-lf int limit number of open files to N\n"); #endif #ifdef RLIMIT_STACK ErrorF("-ls int limit stack space to N Kb\n"); #endif ErrorF("-nolock disable the locking mechanism\n"); ErrorF("-nolisten string don't listen on protocol\n"); ErrorF("-noreset don't reset after last client exists\n"); ErrorF("-background [none] create root window with no background\n"); ErrorF("-reset reset after last client exists\n"); ErrorF("-p # screen-saver pattern duration (minutes)\n"); ErrorF("-pn accept failure to listen on all ports\n"); ErrorF("-nopn reject failure to listen on all ports\n"); ErrorF("-r turns off auto-repeat\n"); ErrorF("r turns on auto-repeat \n"); ErrorF("-render [default|mono|gray|color] set render color alloc policy\n"); ErrorF("-retro start with classic stipple and cursor\n"); ErrorF("-s # screen-saver timeout (minutes)\n"); ErrorF("-seat string seat to run on\n"); ErrorF("-t # default pointer threshold (pixels/t)\n"); ErrorF("-terminate terminate at server reset\n"); ErrorF("-to # connection time out\n"); ErrorF("-tst disable testing extensions\n"); ErrorF("ttyxx server started from init on /dev/ttyxx\n"); ErrorF("v video blanking for screen-saver\n"); ErrorF("-v screen-saver without video blanking\n"); ErrorF("-wm WhenMapped default backing-store\n"); ErrorF("-wr create root window with white background\n"); ErrorF("-maxbigreqsize set maximal bigrequest size \n"); #ifdef PANORAMIX ErrorF("+xinerama Enable XINERAMA extension\n"); ErrorF("-xinerama Disable XINERAMA extension\n"); #endif ErrorF("-dumbSched Disable smart scheduling, enable old behavior\n"); ErrorF("-schedInterval int Set scheduler interval in msec\n"); ErrorF("-sigstop Enable SIGSTOP based startup\n"); ErrorF("+extension name Enable extension\n"); ErrorF("-extension name Disable extension\n"); #ifdef XDMCP XdmcpUseMsg(); #endif XkbUseMsg(); ddxUseMsg(); }
DoS
0
void UseMsg(void) { ErrorF("use: X [:<display>] [option]\n"); ErrorF("-a # default pointer acceleration (factor)\n"); ErrorF("-ac disable access control restrictions\n"); ErrorF("-audit int set audit trail level\n"); ErrorF("-auth file select authorization file\n"); ErrorF("-br create root window with black background\n"); ErrorF("+bs enable any backing store support\n"); ErrorF("-bs disable any backing store support\n"); ErrorF("-c turns off key-click\n"); ErrorF("c # key-click volume (0-100)\n"); ErrorF("-cc int default color visual class\n"); ErrorF("-nocursor disable the cursor\n"); ErrorF("-core generate core dump on fatal error\n"); ErrorF("-dpi int screen resolution in dots per inch\n"); #ifdef DPMSExtension ErrorF("-dpms disables VESA DPMS monitor control\n"); #endif ErrorF("-deferglyphs [none|all|16] defer loading of [no|all|16-bit] glyphs\n"); ErrorF("-f # bell base (0-100)\n"); ErrorF("-fc string cursor font\n"); ErrorF("-fn string default font name\n"); ErrorF("-fp string default font path\n"); ErrorF("-help prints message with these options\n"); ErrorF("-I ignore all remaining arguments\n"); #ifdef RLIMIT_DATA ErrorF("-ld int limit data space to N Kb\n"); #endif #ifdef RLIMIT_NOFILE ErrorF("-lf int limit number of open files to N\n"); #endif #ifdef RLIMIT_STACK ErrorF("-ls int limit stack space to N Kb\n"); #endif ErrorF("-nolock disable the locking mechanism\n"); ErrorF("-nolisten string don't listen on protocol\n"); ErrorF("-noreset don't reset after last client exists\n"); ErrorF("-background [none] create root window with no background\n"); ErrorF("-reset reset after last client exists\n"); ErrorF("-p # screen-saver pattern duration (minutes)\n"); ErrorF("-pn accept failure to listen on all ports\n"); ErrorF("-nopn reject failure to listen on all ports\n"); ErrorF("-r turns off auto-repeat\n"); ErrorF("r turns on auto-repeat \n"); ErrorF("-render [default|mono|gray|color] set render color alloc policy\n"); ErrorF("-retro start with classic stipple and cursor\n"); ErrorF("-s # screen-saver timeout (minutes)\n"); ErrorF("-seat string seat to run on\n"); ErrorF("-t # default pointer threshold (pixels/t)\n"); ErrorF("-terminate terminate at server reset\n"); ErrorF("-to # connection time out\n"); ErrorF("-tst disable testing extensions\n"); ErrorF("ttyxx server started from init on /dev/ttyxx\n"); ErrorF("v video blanking for screen-saver\n"); ErrorF("-v screen-saver without video blanking\n"); ErrorF("-wm WhenMapped default backing-store\n"); ErrorF("-wr create root window with white background\n"); ErrorF("-maxbigreqsize set maximal bigrequest size \n"); #ifdef PANORAMIX ErrorF("+xinerama Enable XINERAMA extension\n"); ErrorF("-xinerama Disable XINERAMA extension\n"); #endif ErrorF("-dumbSched Disable smart scheduling, enable old behavior\n"); ErrorF("-schedInterval int Set scheduler interval in msec\n"); ErrorF("-sigstop Enable SIGSTOP based startup\n"); ErrorF("+extension name Enable extension\n"); ErrorF("-extension name Disable extension\n"); #ifdef XDMCP XdmcpUseMsg(); #endif XkbUseMsg(); ddxUseMsg(); }
@@ -297,7 +297,7 @@ LockServer(void) FatalError("Could not create lock file in %s\n", tmp); (void) sprintf(pid_str, "%10ld\n", (long)getpid()); (void) write(lfd, pid_str, 11); - (void) chmod(tmp, 0444); + (void) fchmod(lfd, 0444); (void) close(lfd); /*
CWE-362
null
null
10,704
XNFstrdup(const char *s) { char *ret; if (s == NULL) return NULL; ret = strdup(s); if (!ret) FatalError("XNFstrdup: Out of memory"); return ret; }
DoS
0
XNFstrdup(const char *s) { char *ret; if (s == NULL) return NULL; ret = strdup(s); if (!ret) FatalError("XNFstrdup: Out of memory"); return ret; }
@@ -297,7 +297,7 @@ LockServer(void) FatalError("Could not create lock file in %s\n", tmp); (void) sprintf(pid_str, "%10ld\n", (long)getpid()); (void) write(lfd, pid_str, 11); - (void) chmod(tmp, 0444); + (void) fchmod(lfd, 0444); (void) close(lfd); /*
CWE-362
null
null
10,705
Xalloc(unsigned long amount) { /* * Xalloc used to return NULL when large amount of memory is requested. In * order to catch the buggy callers this warning has been added, slated to * removal by anyone who touches this code (or just looks at it) in 2011. * * -- Mikhail Gusarov */ if ((long)amount <= 0) ErrorF("Warning: Xalloc: " "requesting unpleasantly large amount of memory: %lu bytes.\n", amount); return malloc(amount); }
DoS
0
Xalloc(unsigned long amount) { /* * Xalloc used to return NULL when large amount of memory is requested. In * order to catch the buggy callers this warning has been added, slated to * removal by anyone who touches this code (or just looks at it) in 2011. * * -- Mikhail Gusarov */ if ((long)amount <= 0) ErrorF("Warning: Xalloc: " "requesting unpleasantly large amount of memory: %lu bytes.\n", amount); return malloc(amount); }
@@ -297,7 +297,7 @@ LockServer(void) FatalError("Could not create lock file in %s\n", tmp); (void) sprintf(pid_str, "%10ld\n", (long)getpid()); (void) write(lfd, pid_str, 11); - (void) chmod(tmp, 0444); + (void) fchmod(lfd, 0444); (void) close(lfd); /*
CWE-362
null
null
10,706
Xfree(void *ptr) { free(ptr); }
DoS
0
Xfree(void *ptr) { free(ptr); }
@@ -297,7 +297,7 @@ LockServer(void) FatalError("Could not create lock file in %s\n", tmp); (void) sprintf(pid_str, "%10ld\n", (long)getpid()); (void) write(lfd, pid_str, 11); - (void) chmod(tmp, 0444); + (void) fchmod(lfd, 0444); (void) close(lfd); /*
CWE-362
null
null
10,707
Xrealloc(void *ptr, unsigned long amount) { /* * Xrealloc used to return NULL when large amount of memory is requested. In * order to catch the buggy callers this warning has been added, slated to * removal by anyone who touches this code (or just looks at it) in 2011. * * -- Mikhail Gusarov */ if ((long)amount <= 0) ErrorF("Warning: Xrealloc: " "requesting unpleasantly large amount of memory: %lu bytes.\n", amount); return realloc(ptr, amount); }
DoS
0
Xrealloc(void *ptr, unsigned long amount) { /* * Xrealloc used to return NULL when large amount of memory is requested. In * order to catch the buggy callers this warning has been added, slated to * removal by anyone who touches this code (or just looks at it) in 2011. * * -- Mikhail Gusarov */ if ((long)amount <= 0) ErrorF("Warning: Xrealloc: " "requesting unpleasantly large amount of memory: %lu bytes.\n", amount); return realloc(ptr, amount); }
@@ -297,7 +297,7 @@ LockServer(void) FatalError("Could not create lock file in %s\n", tmp); (void) sprintf(pid_str, "%10ld\n", (long)getpid()); (void) write(lfd, pid_str, 11); - (void) chmod(tmp, 0444); + (void) fchmod(lfd, 0444); (void) close(lfd); /*
CWE-362
null
null
10,708
set_font_authorizations(char **authorizations, int *authlen, pointer client) { #define AUTHORIZATION_NAME "hp-hostname-1" #if defined(TCPCONN) || defined(STREAMSCONN) static char *result = NULL; static char *p = NULL; if (p == NULL) { char hname[1024], *hnameptr; unsigned int len; #if defined(IPv6) && defined(AF_INET6) struct addrinfo hints, *ai = NULL; #else struct hostent *host; #ifdef XTHREADS_NEEDS_BYNAMEPARAMS _Xgethostbynameparams hparams; #endif #endif gethostname(hname, 1024); #if defined(IPv6) && defined(AF_INET6) memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_CANONNAME; if (getaddrinfo(hname, NULL, &hints, &ai) == 0) { hnameptr = ai->ai_canonname; } else { hnameptr = hname; } #else host = _XGethostbyname(hname, hparams); if (host == NULL) hnameptr = hname; else hnameptr = host->h_name; #endif len = strlen(hnameptr) + 1; result = malloc(len + sizeof(AUTHORIZATION_NAME) + 4); p = result; *p++ = sizeof(AUTHORIZATION_NAME) >> 8; *p++ = sizeof(AUTHORIZATION_NAME) & 0xff; *p++ = (len) >> 8; *p++ = (len & 0xff); memmove(p, AUTHORIZATION_NAME, sizeof(AUTHORIZATION_NAME)); p += sizeof(AUTHORIZATION_NAME); memmove(p, hnameptr, len); p += len; #if defined(IPv6) && defined(AF_INET6) if (ai) { freeaddrinfo(ai); } #endif } *authlen = p - result; *authorizations = result; return 1; #else /* TCPCONN */ return 0; #endif /* TCPCONN */ }
DoS
0
set_font_authorizations(char **authorizations, int *authlen, pointer client) { #define AUTHORIZATION_NAME "hp-hostname-1" #if defined(TCPCONN) || defined(STREAMSCONN) static char *result = NULL; static char *p = NULL; if (p == NULL) { char hname[1024], *hnameptr; unsigned int len; #if defined(IPv6) && defined(AF_INET6) struct addrinfo hints, *ai = NULL; #else struct hostent *host; #ifdef XTHREADS_NEEDS_BYNAMEPARAMS _Xgethostbynameparams hparams; #endif #endif gethostname(hname, 1024); #if defined(IPv6) && defined(AF_INET6) memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_CANONNAME; if (getaddrinfo(hname, NULL, &hints, &ai) == 0) { hnameptr = ai->ai_canonname; } else { hnameptr = hname; } #else host = _XGethostbyname(hname, hparams); if (host == NULL) hnameptr = hname; else hnameptr = host->h_name; #endif len = strlen(hnameptr) + 1; result = malloc(len + sizeof(AUTHORIZATION_NAME) + 4); p = result; *p++ = sizeof(AUTHORIZATION_NAME) >> 8; *p++ = sizeof(AUTHORIZATION_NAME) & 0xff; *p++ = (len) >> 8; *p++ = (len & 0xff); memmove(p, AUTHORIZATION_NAME, sizeof(AUTHORIZATION_NAME)); p += sizeof(AUTHORIZATION_NAME); memmove(p, hnameptr, len); p += len; #if defined(IPv6) && defined(AF_INET6) if (ai) { freeaddrinfo(ai); } #endif } *authlen = p - result; *authorizations = result; return 1; #else /* TCPCONN */ return 0; #endif /* TCPCONN */ }
@@ -297,7 +297,7 @@ LockServer(void) FatalError("Could not create lock file in %s\n", tmp); (void) sprintf(pid_str, "%10ld\n", (long)getpid()); (void) write(lfd, pid_str, 11); - (void) chmod(tmp, 0444); + (void) fchmod(lfd, 0444); (void) close(lfd); /*
CWE-362
null
null
10,709
xstrtokenize(const char *str, const char *separators) { char **list, **nlist; char *tok, *tmp; unsigned num = 0, n; if (!str) return NULL; list = calloc(1, sizeof(*list)); if (!list) return NULL; tmp = strdup(str); if (!tmp) goto error; for (tok = strtok(tmp, separators); tok; tok = strtok(NULL, separators)) { nlist = realloc(list, (num + 2) * sizeof(*list)); if (!nlist) goto error; list = nlist; list[num] = strdup(tok); if (!list[num]) goto error; list[++num] = NULL; } free(tmp); return list; error: free(tmp); for (n = 0; n < num; n++) free(list[n]); free(list); return NULL; }
DoS
0
xstrtokenize(const char *str, const char *separators) { char **list, **nlist; char *tok, *tmp; unsigned num = 0, n; if (!str) return NULL; list = calloc(1, sizeof(*list)); if (!list) return NULL; tmp = strdup(str); if (!tmp) goto error; for (tok = strtok(tmp, separators); tok; tok = strtok(NULL, separators)) { nlist = realloc(list, (num + 2) * sizeof(*list)); if (!nlist) goto error; list = nlist; list[num] = strdup(tok); if (!list[num]) goto error; list[++num] = NULL; } free(tmp); return list; error: free(tmp); for (n = 0; n < num; n++) free(list[n]); free(list); return NULL; }
@@ -297,7 +297,7 @@ LockServer(void) FatalError("Could not create lock file in %s\n", tmp); (void) sprintf(pid_str, "%10ld\n", (long)getpid()); (void) write(lfd, pid_str, 11); - (void) chmod(tmp, 0444); + (void) fchmod(lfd, 0444); (void) close(lfd); /*
CWE-362
null
null
10,710
CreateColors( char **dataptr, unsigned int *data_size, XpmColor *colors, unsigned int ncolors, unsigned int cpp) { char buf[BUFSIZ]; unsigned int a, key, l; char *s, *s2; char **defaults; /* can ncolors be trusted here? */ for (a = 0; a < ncolors; a++, colors++, dataptr++) { defaults = (char **) colors; if(sizeof(buf) <= cpp) return(XpmNoMemory); strncpy(buf, *defaults++, cpp); s = buf + cpp; if(sizeof(buf) <= (s-buf)) return XpmNoMemory; for (key = 1; key <= NKEYS; key++, defaults++) { if ((s2 = *defaults)) { #ifndef VOID_SPRINTF s += #endif /* assume C99 compliance */ snprintf(s, sizeof(buf)-(s-buf), "\t%s %s", xpmColorKeys[key - 1], s2); #ifdef VOID_SPRINTF s += strlen(s); #endif /* does s point out-of-bounds? */ if(sizeof(buf) < (s-buf)) return XpmNoMemory; } } /* what about using strdup()? */ l = s - buf + 1; s = (char *) XpmMalloc(l); if (!s) return (XpmNoMemory); *data_size += l; *dataptr = strcpy(s, buf); } return (XpmSuccess); }
DoS Exec Code Overflow
0
CreateColors( char **dataptr, unsigned int *data_size, XpmColor *colors, unsigned int ncolors, unsigned int cpp) { char buf[BUFSIZ]; unsigned int a, key, l; char *s, *s2; char **defaults; /* can ncolors be trusted here? */ for (a = 0; a < ncolors; a++, colors++, dataptr++) { defaults = (char **) colors; if(sizeof(buf) <= cpp) return(XpmNoMemory); strncpy(buf, *defaults++, cpp); s = buf + cpp; if(sizeof(buf) <= (s-buf)) return XpmNoMemory; for (key = 1; key <= NKEYS; key++, defaults++) { if ((s2 = *defaults)) { #ifndef VOID_SPRINTF s += #endif /* assume C99 compliance */ snprintf(s, sizeof(buf)-(s-buf), "\t%s %s", xpmColorKeys[key - 1], s2); #ifdef VOID_SPRINTF s += strlen(s); #endif /* does s point out-of-bounds? */ if(sizeof(buf) < (s-buf)) return XpmNoMemory; } } /* what about using strdup()? */ l = s - buf + 1; s = (char *) XpmMalloc(l); if (!s) return (XpmNoMemory); *data_size += l; *dataptr = strcpy(s, buf); } return (XpmSuccess); }
@@ -48,7 +48,7 @@ LFUNC(CreatePixels, void, (char **dataptr, unsigned int data_size, unsigned int height, unsigned int cpp, unsigned int *pixels, XpmColor *colors)); -LFUNC(CountExtensions, void, (XpmExtension *ext, unsigned int num, +LFUNC(CountExtensions, int, (XpmExtension *ext, unsigned int num, unsigned int *ext_size, unsigned int *ext_nlines)); @@ -122,8 +122,9 @@ XpmCreateDataFromXpmImage( /* compute the number of extensions lines and size */ if (extensions) - CountExtensions(info->extensions, info->nextensions, - &ext_size, &ext_nlines); + if (CountExtensions(info->extensions, info->nextensions, + &ext_size, &ext_nlines)) + return(XpmNoMemory); /* * alloc a temporary array of char pointer for the header section which @@ -187,7 +188,8 @@ XpmCreateDataFromXpmImage( if(offset <= image->width || offset <= image->cpp) RETURN(XpmNoMemory); - if( (image->height + ext_nlines) >= UINT_MAX / sizeof(char *)) + if (image->height > UINT_MAX - ext_nlines || + image->height + ext_nlines >= UINT_MAX / sizeof(char *)) RETURN(XpmNoMemory); data_size = (image->height + ext_nlines) * sizeof(char *); @@ -196,7 +198,8 @@ XpmCreateDataFromXpmImage( RETURN(XpmNoMemory); data_size += image->height * offset; - if( (header_size + ext_size) >= (UINT_MAX - data_size) ) + if (header_size > UINT_MAX - ext_size || + header_size + ext_size >= (UINT_MAX - data_size) ) RETURN(XpmNoMemory); data_size += header_size + ext_size; @@ -343,13 +346,14 @@ CreatePixels( *s = '\0'; } -static void +static int CountExtensions( XpmExtension *ext, unsigned int num, unsigned int *ext_size, unsigned int *ext_nlines) { + size_t len; unsigned int x, y, a, size, nlines; char **line; @@ -357,16 +361,28 @@ CountExtensions( nlines = 0; for (x = 0; x < num; x++, ext++) { /* 1 for the name */ + if (ext->nlines == UINT_MAX || nlines > UINT_MAX - ext->nlines - 1) + return (1); nlines += ext->nlines + 1; /* 8 = 7 (for "XPMEXT ") + 1 (for 0) */ - size += strlen(ext->name) + 8; + len = strlen(ext->name) + 8; + if (len > UINT_MAX - size) + return (1); + size += len; a = ext->nlines; - for (y = 0, line = ext->lines; y < a; y++, line++) - size += strlen(*line) + 1; + for (y = 0, line = ext->lines; y < a; y++, line++) { + len = strlen(*line) + 1; + if (len > UINT_MAX - size) + return (1); + size += len; + } } + if (size > UINT_MAX - 10 || nlines > UINT_MAX - 1) + return (1); /* 10 and 1 are for the ending "XPMENDEXT" */ *ext_size = size + 10; *ext_nlines = nlines + 1; + return (0); } static void
CWE-787
null
null
10,711
XpmCreateDataFromImage( Display *display, char ***data_return, XImage *image, XImage *shapeimage, XpmAttributes *attributes) { XpmImage xpmimage; XpmInfo info; int ErrorStatus; /* initialize return value */ if (data_return) *data_return = NULL; /* create an XpmImage from the image */ ErrorStatus = XpmCreateXpmImageFromImage(display, image, shapeimage, &xpmimage, attributes); if (ErrorStatus != XpmSuccess) return (ErrorStatus); /* create the data from the XpmImage */ if (attributes) { xpmSetInfo(&info, attributes); ErrorStatus = XpmCreateDataFromXpmImage(data_return, &xpmimage, &info); } else ErrorStatus = XpmCreateDataFromXpmImage(data_return, &xpmimage, NULL); /* free the XpmImage */ XpmFreeXpmImage(&xpmimage); return (ErrorStatus); }
DoS Exec Code Overflow
0
XpmCreateDataFromImage( Display *display, char ***data_return, XImage *image, XImage *shapeimage, XpmAttributes *attributes) { XpmImage xpmimage; XpmInfo info; int ErrorStatus; /* initialize return value */ if (data_return) *data_return = NULL; /* create an XpmImage from the image */ ErrorStatus = XpmCreateXpmImageFromImage(display, image, shapeimage, &xpmimage, attributes); if (ErrorStatus != XpmSuccess) return (ErrorStatus); /* create the data from the XpmImage */ if (attributes) { xpmSetInfo(&info, attributes); ErrorStatus = XpmCreateDataFromXpmImage(data_return, &xpmimage, &info); } else ErrorStatus = XpmCreateDataFromXpmImage(data_return, &xpmimage, NULL); /* free the XpmImage */ XpmFreeXpmImage(&xpmimage); return (ErrorStatus); }
@@ -48,7 +48,7 @@ LFUNC(CreatePixels, void, (char **dataptr, unsigned int data_size, unsigned int height, unsigned int cpp, unsigned int *pixels, XpmColor *colors)); -LFUNC(CountExtensions, void, (XpmExtension *ext, unsigned int num, +LFUNC(CountExtensions, int, (XpmExtension *ext, unsigned int num, unsigned int *ext_size, unsigned int *ext_nlines)); @@ -122,8 +122,9 @@ XpmCreateDataFromXpmImage( /* compute the number of extensions lines and size */ if (extensions) - CountExtensions(info->extensions, info->nextensions, - &ext_size, &ext_nlines); + if (CountExtensions(info->extensions, info->nextensions, + &ext_size, &ext_nlines)) + return(XpmNoMemory); /* * alloc a temporary array of char pointer for the header section which @@ -187,7 +188,8 @@ XpmCreateDataFromXpmImage( if(offset <= image->width || offset <= image->cpp) RETURN(XpmNoMemory); - if( (image->height + ext_nlines) >= UINT_MAX / sizeof(char *)) + if (image->height > UINT_MAX - ext_nlines || + image->height + ext_nlines >= UINT_MAX / sizeof(char *)) RETURN(XpmNoMemory); data_size = (image->height + ext_nlines) * sizeof(char *); @@ -196,7 +198,8 @@ XpmCreateDataFromXpmImage( RETURN(XpmNoMemory); data_size += image->height * offset; - if( (header_size + ext_size) >= (UINT_MAX - data_size) ) + if (header_size > UINT_MAX - ext_size || + header_size + ext_size >= (UINT_MAX - data_size) ) RETURN(XpmNoMemory); data_size += header_size + ext_size; @@ -343,13 +346,14 @@ CreatePixels( *s = '\0'; } -static void +static int CountExtensions( XpmExtension *ext, unsigned int num, unsigned int *ext_size, unsigned int *ext_nlines) { + size_t len; unsigned int x, y, a, size, nlines; char **line; @@ -357,16 +361,28 @@ CountExtensions( nlines = 0; for (x = 0; x < num; x++, ext++) { /* 1 for the name */ + if (ext->nlines == UINT_MAX || nlines > UINT_MAX - ext->nlines - 1) + return (1); nlines += ext->nlines + 1; /* 8 = 7 (for "XPMEXT ") + 1 (for 0) */ - size += strlen(ext->name) + 8; + len = strlen(ext->name) + 8; + if (len > UINT_MAX - size) + return (1); + size += len; a = ext->nlines; - for (y = 0, line = ext->lines; y < a; y++, line++) - size += strlen(*line) + 1; + for (y = 0, line = ext->lines; y < a; y++, line++) { + len = strlen(*line) + 1; + if (len > UINT_MAX - size) + return (1); + size += len; + } } + if (size > UINT_MAX - 10 || nlines > UINT_MAX - 1) + return (1); /* 10 and 1 are for the ending "XPMENDEXT" */ *ext_size = size + 10; *ext_nlines = nlines + 1; + return (0); } static void
CWE-787
null
null
10,712
static int vrend_decode_create_ve(struct vrend_decode_ctx *ctx, uint32_t handle, uint16_t length) { struct pipe_vertex_element *ve = NULL; int num_elements; int i; int ret; if (length < 1) return EINVAL; if ((length - 1) % 4) return EINVAL; num_elements = (length - 1) / 4; if (num_elements) { ve = calloc(num_elements, sizeof(struct pipe_vertex_element)); if (!ve) return ENOMEM; for (i = 0; i < num_elements; i++) { ve[i].src_offset = get_buf_entry(ctx, VIRGL_OBJ_VERTEX_ELEMENTS_V0_SRC_OFFSET(i)); ve[i].instance_divisor = get_buf_entry(ctx, VIRGL_OBJ_VERTEX_ELEMENTS_V0_INSTANCE_DIVISOR(i)); ve[i].vertex_buffer_index = get_buf_entry(ctx, VIRGL_OBJ_VERTEX_ELEMENTS_V0_VERTEX_BUFFER_INDEX(i)); ve[i].src_format = get_buf_entry(ctx, VIRGL_OBJ_VERTEX_ELEMENTS_V0_SRC_FORMAT(i)); } } ret = vrend_create_vertex_elements_state(ctx->grctx, handle, num_elements, ve); FREE(ve); return ret; }
DoS
0
static int vrend_decode_create_ve(struct vrend_decode_ctx *ctx, uint32_t handle, uint16_t length) { struct pipe_vertex_element *ve = NULL; int num_elements; int i; int ret; if (length < 1) return EINVAL; if ((length - 1) % 4) return EINVAL; num_elements = (length - 1) / 4; if (num_elements) { ve = calloc(num_elements, sizeof(struct pipe_vertex_element)); if (!ve) return ENOMEM; for (i = 0; i < num_elements; i++) { ve[i].src_offset = get_buf_entry(ctx, VIRGL_OBJ_VERTEX_ELEMENTS_V0_SRC_OFFSET(i)); ve[i].instance_divisor = get_buf_entry(ctx, VIRGL_OBJ_VERTEX_ELEMENTS_V0_INSTANCE_DIVISOR(i)); ve[i].vertex_buffer_index = get_buf_entry(ctx, VIRGL_OBJ_VERTEX_ELEMENTS_V0_VERTEX_BUFFER_INDEX(i)); ve[i].src_format = get_buf_entry(ctx, VIRGL_OBJ_VERTEX_ELEMENTS_V0_SRC_FORMAT(i)); } } ret = vrend_create_vertex_elements_state(ctx->grctx, handle, num_elements, ve); FREE(ve); return ret; }
@@ -1045,6 +1045,10 @@ void vrend_renderer_context_create_internal(uint32_t handle, uint32_t nlen, if (handle >= VREND_MAX_CTX) return; + dctx = dec_ctx[handle]; + if (dctx) + return; + dctx = malloc(sizeof(struct vrend_decode_ctx)); if (!dctx) return;
CWE-399
null
null
10,713
static int vrend_decode_set_framebuffer_state(struct vrend_decode_ctx *ctx, int length) { if (length < 2) return EINVAL; uint32_t nr_cbufs = get_buf_entry(ctx, VIRGL_SET_FRAMEBUFFER_STATE_NR_CBUFS); uint32_t zsurf_handle = get_buf_entry(ctx, VIRGL_SET_FRAMEBUFFER_STATE_NR_ZSURF_HANDLE); uint32_t surf_handle[8]; int i; if (length != (2 + nr_cbufs)) return EINVAL; for (i = 0; i < nr_cbufs; i++) surf_handle[i] = get_buf_entry(ctx, VIRGL_SET_FRAMEBUFFER_STATE_CBUF_HANDLE(i)); vrend_set_framebuffer_state(ctx->grctx, nr_cbufs, surf_handle, zsurf_handle); return 0; }
DoS
0
static int vrend_decode_set_framebuffer_state(struct vrend_decode_ctx *ctx, int length) { if (length < 2) return EINVAL; uint32_t nr_cbufs = get_buf_entry(ctx, VIRGL_SET_FRAMEBUFFER_STATE_NR_CBUFS); uint32_t zsurf_handle = get_buf_entry(ctx, VIRGL_SET_FRAMEBUFFER_STATE_NR_ZSURF_HANDLE); uint32_t surf_handle[8]; int i; if (length != (2 + nr_cbufs)) return EINVAL; for (i = 0; i < nr_cbufs; i++) surf_handle[i] = get_buf_entry(ctx, VIRGL_SET_FRAMEBUFFER_STATE_CBUF_HANDLE(i)); vrend_set_framebuffer_state(ctx->grctx, nr_cbufs, surf_handle, zsurf_handle); return 0; }
@@ -1045,6 +1045,10 @@ void vrend_renderer_context_create_internal(uint32_t handle, uint32_t nlen, if (handle >= VREND_MAX_CTX) return; + dctx = dec_ctx[handle]; + if (dctx) + return; + dctx = malloc(sizeof(struct vrend_decode_ctx)); if (!dctx) return;
CWE-399
null
null
10,714
static uint32_t i6300esb_config_read(PCIDevice *dev, uint32_t addr, int len) { I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); uint32_t data; i6300esb_debug ("addr = %x, len = %d\n", addr, len); if (addr == ESB_CONFIG_REG && len == 2) { data = (d->reboot_enabled ? 0 : ESB_WDT_REBOOT) | (d->clock_scale == CLOCK_SCALE_1MHZ ? ESB_WDT_FREQ : 0) | d->int_type; return data; } else if (addr == ESB_LOCK_REG && len == 1) { data = (d->free_run ? ESB_WDT_FUNC : 0) | (d->locked ? ESB_WDT_LOCK : 0) | (d->enabled ? ESB_WDT_ENABLE : 0); return data; } else { return pci_default_read_config(dev, addr, len); } }
DoS
0
static uint32_t i6300esb_config_read(PCIDevice *dev, uint32_t addr, int len) { I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); uint32_t data; i6300esb_debug ("addr = %x, len = %d\n", addr, len); if (addr == ESB_CONFIG_REG && len == 2) { data = (d->reboot_enabled ? 0 : ESB_WDT_REBOOT) | (d->clock_scale == CLOCK_SCALE_1MHZ ? ESB_WDT_FREQ : 0) | d->int_type; return data; } else if (addr == ESB_LOCK_REG && len == 1) { data = (d->free_run ? ESB_WDT_FUNC : 0) | (d->locked ? ESB_WDT_LOCK : 0) | (d->enabled ? ESB_WDT_ENABLE : 0); return data; } else { return pci_default_read_config(dev, addr, len); } }
@@ -428,6 +428,14 @@ static void i6300esb_realize(PCIDevice *dev, Error **errp) /* qemu_register_coalesced_mmio (addr, 0x10); ? */ } +static void i6300esb_exit(PCIDevice *dev) +{ + I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); + + timer_del(d->timer); + timer_free(d->timer); +} + static WatchdogTimerModel model = { .wdt_name = "i6300esb", .wdt_description = "Intel 6300ESB", @@ -441,6 +449,7 @@ static void i6300esb_class_init(ObjectClass *klass, void *data) k->config_read = i6300esb_config_read; k->config_write = i6300esb_config_write; k->realize = i6300esb_realize; + k->exit = i6300esb_exit; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_ESB_9; k->class_id = PCI_CLASS_SYSTEM_OTHER;
CWE-399
null
null
10,715
static void i6300esb_config_write(PCIDevice *dev, uint32_t addr, uint32_t data, int len) { I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); int old; i6300esb_debug("addr = %x, data = %x, len = %d\n", addr, data, len); if (addr == ESB_CONFIG_REG && len == 2) { d->reboot_enabled = (data & ESB_WDT_REBOOT) == 0; d->clock_scale = (data & ESB_WDT_FREQ) != 0 ? CLOCK_SCALE_1MHZ : CLOCK_SCALE_1KHZ; d->int_type = (data & ESB_WDT_INTTYPE); } else if (addr == ESB_LOCK_REG && len == 1) { if (!d->locked) { d->locked = (data & ESB_WDT_LOCK) != 0; d->free_run = (data & ESB_WDT_FUNC) != 0; old = d->enabled; d->enabled = (data & ESB_WDT_ENABLE) != 0; if (!old && d->enabled) /* Enabled transitioned from 0 -> 1 */ i6300esb_restart_timer(d, 1); else if (!d->enabled) i6300esb_disable_timer(d); } } else { pci_default_write_config(dev, addr, data, len); } }
DoS
0
static void i6300esb_config_write(PCIDevice *dev, uint32_t addr, uint32_t data, int len) { I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); int old; i6300esb_debug("addr = %x, data = %x, len = %d\n", addr, data, len); if (addr == ESB_CONFIG_REG && len == 2) { d->reboot_enabled = (data & ESB_WDT_REBOOT) == 0; d->clock_scale = (data & ESB_WDT_FREQ) != 0 ? CLOCK_SCALE_1MHZ : CLOCK_SCALE_1KHZ; d->int_type = (data & ESB_WDT_INTTYPE); } else if (addr == ESB_LOCK_REG && len == 1) { if (!d->locked) { d->locked = (data & ESB_WDT_LOCK) != 0; d->free_run = (data & ESB_WDT_FUNC) != 0; old = d->enabled; d->enabled = (data & ESB_WDT_ENABLE) != 0; if (!old && d->enabled) /* Enabled transitioned from 0 -> 1 */ i6300esb_restart_timer(d, 1); else if (!d->enabled) i6300esb_disable_timer(d); } } else { pci_default_write_config(dev, addr, data, len); } }
@@ -428,6 +428,14 @@ static void i6300esb_realize(PCIDevice *dev, Error **errp) /* qemu_register_coalesced_mmio (addr, 0x10); ? */ } +static void i6300esb_exit(PCIDevice *dev) +{ + I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); + + timer_del(d->timer); + timer_free(d->timer); +} + static WatchdogTimerModel model = { .wdt_name = "i6300esb", .wdt_description = "Intel 6300ESB", @@ -441,6 +449,7 @@ static void i6300esb_class_init(ObjectClass *klass, void *data) k->config_read = i6300esb_config_read; k->config_write = i6300esb_config_write; k->realize = i6300esb_realize; + k->exit = i6300esb_exit; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_ESB_9; k->class_id = PCI_CLASS_SYSTEM_OTHER;
CWE-399
null
null
10,716
static uint32_t i6300esb_mem_readl(void *vp, hwaddr addr) { i6300esb_debug("addr = %x\n", (int) addr); return 0; }
DoS
0
static uint32_t i6300esb_mem_readl(void *vp, hwaddr addr) { i6300esb_debug("addr = %x\n", (int) addr); return 0; }
@@ -428,6 +428,14 @@ static void i6300esb_realize(PCIDevice *dev, Error **errp) /* qemu_register_coalesced_mmio (addr, 0x10); ? */ } +static void i6300esb_exit(PCIDevice *dev) +{ + I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); + + timer_del(d->timer); + timer_free(d->timer); +} + static WatchdogTimerModel model = { .wdt_name = "i6300esb", .wdt_description = "Intel 6300ESB", @@ -441,6 +449,7 @@ static void i6300esb_class_init(ObjectClass *klass, void *data) k->config_read = i6300esb_config_read; k->config_write = i6300esb_config_write; k->realize = i6300esb_realize; + k->exit = i6300esb_exit; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_ESB_9; k->class_id = PCI_CLASS_SYSTEM_OTHER;
CWE-399
null
null
10,717
static uint32_t i6300esb_mem_readw(void *vp, hwaddr addr) { uint32_t data = 0; I6300State *d = vp; i6300esb_debug("addr = %x\n", (int) addr); if (addr == 0xc) { /* The previous reboot flag is really bit 9, but there is * a bug in the Linux driver where it thinks it's bit 12. * Set both. */ data = d->previous_reboot_flag ? 0x1200 : 0; } return data; }
DoS
0
static uint32_t i6300esb_mem_readw(void *vp, hwaddr addr) { uint32_t data = 0; I6300State *d = vp; i6300esb_debug("addr = %x\n", (int) addr); if (addr == 0xc) { /* The previous reboot flag is really bit 9, but there is * a bug in the Linux driver where it thinks it's bit 12. * Set both. */ data = d->previous_reboot_flag ? 0x1200 : 0; } return data; }
@@ -428,6 +428,14 @@ static void i6300esb_realize(PCIDevice *dev, Error **errp) /* qemu_register_coalesced_mmio (addr, 0x10); ? */ } +static void i6300esb_exit(PCIDevice *dev) +{ + I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); + + timer_del(d->timer); + timer_free(d->timer); +} + static WatchdogTimerModel model = { .wdt_name = "i6300esb", .wdt_description = "Intel 6300ESB", @@ -441,6 +449,7 @@ static void i6300esb_class_init(ObjectClass *klass, void *data) k->config_read = i6300esb_config_read; k->config_write = i6300esb_config_write; k->realize = i6300esb_realize; + k->exit = i6300esb_exit; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_ESB_9; k->class_id = PCI_CLASS_SYSTEM_OTHER;
CWE-399
null
null
10,718
static void i6300esb_mem_writeb(void *vp, hwaddr addr, uint32_t val) { I6300State *d = vp; i6300esb_debug("addr = %x, val = %x\n", (int) addr, val); if (addr == 0xc && val == 0x80) d->unlock_state = 1; else if (addr == 0xc && val == 0x86 && d->unlock_state == 1) d->unlock_state = 2; }
DoS
0
static void i6300esb_mem_writeb(void *vp, hwaddr addr, uint32_t val) { I6300State *d = vp; i6300esb_debug("addr = %x, val = %x\n", (int) addr, val); if (addr == 0xc && val == 0x80) d->unlock_state = 1; else if (addr == 0xc && val == 0x86 && d->unlock_state == 1) d->unlock_state = 2; }
@@ -428,6 +428,14 @@ static void i6300esb_realize(PCIDevice *dev, Error **errp) /* qemu_register_coalesced_mmio (addr, 0x10); ? */ } +static void i6300esb_exit(PCIDevice *dev) +{ + I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); + + timer_del(d->timer); + timer_free(d->timer); +} + static WatchdogTimerModel model = { .wdt_name = "i6300esb", .wdt_description = "Intel 6300ESB", @@ -441,6 +449,7 @@ static void i6300esb_class_init(ObjectClass *klass, void *data) k->config_read = i6300esb_config_read; k->config_write = i6300esb_config_write; k->realize = i6300esb_realize; + k->exit = i6300esb_exit; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_ESB_9; k->class_id = PCI_CLASS_SYSTEM_OTHER;
CWE-399
null
null
10,719
static void i6300esb_mem_writel(void *vp, hwaddr addr, uint32_t val) { I6300State *d = vp; i6300esb_debug ("addr = %x, val = %x\n", (int) addr, val); if (addr == 0xc && val == 0x80) d->unlock_state = 1; else if (addr == 0xc && val == 0x86 && d->unlock_state == 1) d->unlock_state = 2; else { if (d->unlock_state == 2) { if (addr == 0) d->timer1_preload = val & 0xfffff; else if (addr == 4) d->timer2_preload = val & 0xfffff; d->unlock_state = 0; } } }
DoS
0
static void i6300esb_mem_writel(void *vp, hwaddr addr, uint32_t val) { I6300State *d = vp; i6300esb_debug ("addr = %x, val = %x\n", (int) addr, val); if (addr == 0xc && val == 0x80) d->unlock_state = 1; else if (addr == 0xc && val == 0x86 && d->unlock_state == 1) d->unlock_state = 2; else { if (d->unlock_state == 2) { if (addr == 0) d->timer1_preload = val & 0xfffff; else if (addr == 4) d->timer2_preload = val & 0xfffff; d->unlock_state = 0; } } }
@@ -428,6 +428,14 @@ static void i6300esb_realize(PCIDevice *dev, Error **errp) /* qemu_register_coalesced_mmio (addr, 0x10); ? */ } +static void i6300esb_exit(PCIDevice *dev) +{ + I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); + + timer_del(d->timer); + timer_free(d->timer); +} + static WatchdogTimerModel model = { .wdt_name = "i6300esb", .wdt_description = "Intel 6300ESB", @@ -441,6 +449,7 @@ static void i6300esb_class_init(ObjectClass *klass, void *data) k->config_read = i6300esb_config_read; k->config_write = i6300esb_config_write; k->realize = i6300esb_realize; + k->exit = i6300esb_exit; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_ESB_9; k->class_id = PCI_CLASS_SYSTEM_OTHER;
CWE-399
null
null
10,720
static void i6300esb_realize(PCIDevice *dev, Error **errp) { I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); i6300esb_debug("I6300State = %p\n", d); d->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, i6300esb_timer_expired, d); d->previous_reboot_flag = 0; memory_region_init_io(&d->io_mem, OBJECT(d), &i6300esb_ops, d, "i6300esb", 0x10); pci_register_bar(&d->dev, 0, 0, &d->io_mem); /* qemu_register_coalesced_mmio (addr, 0x10); ? */ }
DoS
0
static void i6300esb_realize(PCIDevice *dev, Error **errp) { I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); i6300esb_debug("I6300State = %p\n", d); d->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, i6300esb_timer_expired, d); d->previous_reboot_flag = 0; memory_region_init_io(&d->io_mem, OBJECT(d), &i6300esb_ops, d, "i6300esb", 0x10); pci_register_bar(&d->dev, 0, 0, &d->io_mem); /* qemu_register_coalesced_mmio (addr, 0x10); ? */ }
@@ -428,6 +428,14 @@ static void i6300esb_realize(PCIDevice *dev, Error **errp) /* qemu_register_coalesced_mmio (addr, 0x10); ? */ } +static void i6300esb_exit(PCIDevice *dev) +{ + I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); + + timer_del(d->timer); + timer_free(d->timer); +} + static WatchdogTimerModel model = { .wdt_name = "i6300esb", .wdt_description = "Intel 6300ESB", @@ -441,6 +449,7 @@ static void i6300esb_class_init(ObjectClass *klass, void *data) k->config_read = i6300esb_config_read; k->config_write = i6300esb_config_write; k->realize = i6300esb_realize; + k->exit = i6300esb_exit; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_ESB_9; k->class_id = PCI_CLASS_SYSTEM_OTHER;
CWE-399
null
null
10,721
static void i6300esb_register_types(void) { watchdog_add_model(&model); type_register_static(&i6300esb_info); }
DoS
0
static void i6300esb_register_types(void) { watchdog_add_model(&model); type_register_static(&i6300esb_info); }
@@ -428,6 +428,14 @@ static void i6300esb_realize(PCIDevice *dev, Error **errp) /* qemu_register_coalesced_mmio (addr, 0x10); ? */ } +static void i6300esb_exit(PCIDevice *dev) +{ + I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); + + timer_del(d->timer); + timer_free(d->timer); +} + static WatchdogTimerModel model = { .wdt_name = "i6300esb", .wdt_description = "Intel 6300ESB", @@ -441,6 +449,7 @@ static void i6300esb_class_init(ObjectClass *klass, void *data) k->config_read = i6300esb_config_read; k->config_write = i6300esb_config_write; k->realize = i6300esb_realize; + k->exit = i6300esb_exit; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_ESB_9; k->class_id = PCI_CLASS_SYSTEM_OTHER;
CWE-399
null
null
10,722
static void i6300esb_reset(DeviceState *dev) { PCIDevice *pdev = PCI_DEVICE(dev); I6300State *d = WATCHDOG_I6300ESB_DEVICE(pdev); i6300esb_debug("I6300State = %p\n", d); i6300esb_disable_timer(d); /* NB: Don't change d->previous_reboot_flag in this function. */ d->reboot_enabled = 1; d->clock_scale = CLOCK_SCALE_1KHZ; d->int_type = INT_TYPE_IRQ; d->free_run = 0; d->locked = 0; d->enabled = 0; d->timer1_preload = 0xfffff; d->timer2_preload = 0xfffff; d->stage = 1; d->unlock_state = 0; }
DoS
0
static void i6300esb_reset(DeviceState *dev) { PCIDevice *pdev = PCI_DEVICE(dev); I6300State *d = WATCHDOG_I6300ESB_DEVICE(pdev); i6300esb_debug("I6300State = %p\n", d); i6300esb_disable_timer(d); /* NB: Don't change d->previous_reboot_flag in this function. */ d->reboot_enabled = 1; d->clock_scale = CLOCK_SCALE_1KHZ; d->int_type = INT_TYPE_IRQ; d->free_run = 0; d->locked = 0; d->enabled = 0; d->timer1_preload = 0xfffff; d->timer2_preload = 0xfffff; d->stage = 1; d->unlock_state = 0; }
@@ -428,6 +428,14 @@ static void i6300esb_realize(PCIDevice *dev, Error **errp) /* qemu_register_coalesced_mmio (addr, 0x10); ? */ } +static void i6300esb_exit(PCIDevice *dev) +{ + I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); + + timer_del(d->timer); + timer_free(d->timer); +} + static WatchdogTimerModel model = { .wdt_name = "i6300esb", .wdt_description = "Intel 6300ESB", @@ -441,6 +449,7 @@ static void i6300esb_class_init(ObjectClass *klass, void *data) k->config_read = i6300esb_config_read; k->config_write = i6300esb_config_write; k->realize = i6300esb_realize; + k->exit = i6300esb_exit; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_ESB_9; k->class_id = PCI_CLASS_SYSTEM_OTHER;
CWE-399
null
null
10,723
static void i6300esb_restart_timer(I6300State *d, int stage) { int64_t timeout; if (!d->enabled) return; d->stage = stage; if (d->stage <= 1) timeout = d->timer1_preload; else timeout = d->timer2_preload; if (d->clock_scale == CLOCK_SCALE_1KHZ) timeout <<= 15; else timeout <<= 5; /* Get the timeout in nanoseconds. */ timeout = timeout * 30; /* on a PCI bus, 1 tick is 30 ns*/ i6300esb_debug("stage %d, timeout %" PRIi64 "\n", d->stage, timeout); timer_mod(d->timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + timeout); }
DoS
0
static void i6300esb_restart_timer(I6300State *d, int stage) { int64_t timeout; if (!d->enabled) return; d->stage = stage; if (d->stage <= 1) timeout = d->timer1_preload; else timeout = d->timer2_preload; if (d->clock_scale == CLOCK_SCALE_1KHZ) timeout <<= 15; else timeout <<= 5; /* Get the timeout in nanoseconds. */ timeout = timeout * 30; /* on a PCI bus, 1 tick is 30 ns*/ i6300esb_debug("stage %d, timeout %" PRIi64 "\n", d->stage, timeout); timer_mod(d->timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + timeout); }
@@ -428,6 +428,14 @@ static void i6300esb_realize(PCIDevice *dev, Error **errp) /* qemu_register_coalesced_mmio (addr, 0x10); ? */ } +static void i6300esb_exit(PCIDevice *dev) +{ + I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); + + timer_del(d->timer); + timer_free(d->timer); +} + static WatchdogTimerModel model = { .wdt_name = "i6300esb", .wdt_description = "Intel 6300ESB", @@ -441,6 +449,7 @@ static void i6300esb_class_init(ObjectClass *klass, void *data) k->config_read = i6300esb_config_read; k->config_write = i6300esb_config_write; k->realize = i6300esb_realize; + k->exit = i6300esb_exit; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_ESB_9; k->class_id = PCI_CLASS_SYSTEM_OTHER;
CWE-399
null
null
10,724
static void i6300esb_timer_expired(void *vp) { I6300State *d = vp; i6300esb_debug("stage %d\n", d->stage); if (d->stage == 1) { /* What to do at the end of stage 1? */ switch (d->int_type) { case INT_TYPE_IRQ: fprintf(stderr, "i6300esb_timer_expired: I would send APIC 1 INT 10 here if I knew how (XXX)\n"); break; case INT_TYPE_SMI: fprintf(stderr, "i6300esb_timer_expired: I would send SMI here if I knew how (XXX)\n"); break; } /* Start the second stage. */ i6300esb_restart_timer(d, 2); } else { /* Second stage expired, reboot for real. */ if (d->reboot_enabled) { d->previous_reboot_flag = 1; watchdog_perform_action(); /* This reboots, exits, etc */ i6300esb_reset(&d->dev.qdev); } /* In "free running mode" we start stage 1 again. */ if (d->free_run) i6300esb_restart_timer(d, 1); } }
DoS
0
static void i6300esb_timer_expired(void *vp) { I6300State *d = vp; i6300esb_debug("stage %d\n", d->stage); if (d->stage == 1) { /* What to do at the end of stage 1? */ switch (d->int_type) { case INT_TYPE_IRQ: fprintf(stderr, "i6300esb_timer_expired: I would send APIC 1 INT 10 here if I knew how (XXX)\n"); break; case INT_TYPE_SMI: fprintf(stderr, "i6300esb_timer_expired: I would send SMI here if I knew how (XXX)\n"); break; } /* Start the second stage. */ i6300esb_restart_timer(d, 2); } else { /* Second stage expired, reboot for real. */ if (d->reboot_enabled) { d->previous_reboot_flag = 1; watchdog_perform_action(); /* This reboots, exits, etc */ i6300esb_reset(&d->dev.qdev); } /* In "free running mode" we start stage 1 again. */ if (d->free_run) i6300esb_restart_timer(d, 1); } }
@@ -428,6 +428,14 @@ static void i6300esb_realize(PCIDevice *dev, Error **errp) /* qemu_register_coalesced_mmio (addr, 0x10); ? */ } +static void i6300esb_exit(PCIDevice *dev) +{ + I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); + + timer_del(d->timer); + timer_free(d->timer); +} + static WatchdogTimerModel model = { .wdt_name = "i6300esb", .wdt_description = "Intel 6300ESB", @@ -441,6 +449,7 @@ static void i6300esb_class_init(ObjectClass *klass, void *data) k->config_read = i6300esb_config_read; k->config_write = i6300esb_config_write; k->realize = i6300esb_realize; + k->exit = i6300esb_exit; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_ESB_9; k->class_id = PCI_CLASS_SYSTEM_OTHER;
CWE-399
null
null
10,725
static void jsR_callcfunction(js_State *J, int n, int min, js_CFunction F) { int i; js_Value v; for (i = n; i < min; ++i) js_pushundefined(J); F(J); v = *stackidx(J, -1); TOP = --BOT; /* clear stack */ js_pushvalue(J, v); }
Overflow
0
static void jsR_callcfunction(js_State *J, int n, int min, js_CFunction F) { int i; js_Value v; for (i = n; i < min; ++i) js_pushundefined(J); F(J); v = *stackidx(J, -1); TOP = --BOT; /* clear stack */ js_pushvalue(J, v); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,726
static void jsR_callfunction(js_State *J, int n, js_Function *F, js_Environment *scope) { js_Value v; int i; scope = jsR_newenvironment(J, jsV_newobject(J, JS_COBJECT, NULL), scope); jsR_savescope(J, scope); if (F->arguments) { js_newobject(J); if (!J->strict) { js_currentfunction(J); js_defproperty(J, -2, "callee", JS_DONTENUM); } js_pushnumber(J, n); js_defproperty(J, -2, "length", JS_DONTENUM); for (i = 0; i < n; ++i) { js_copy(J, i + 1); js_setindex(J, -2, i); } js_initvar(J, "arguments", -1); js_pop(J, 1); } for (i = 0; i < F->numparams; ++i) { if (i < n) js_initvar(J, F->vartab[i], i + 1); else { js_pushundefined(J); js_initvar(J, F->vartab[i], -1); js_pop(J, 1); } } js_pop(J, n); jsR_run(J, F); v = *stackidx(J, -1); TOP = --BOT; /* clear stack */ js_pushvalue(J, v); jsR_restorescope(J); }
Overflow
0
static void jsR_callfunction(js_State *J, int n, js_Function *F, js_Environment *scope) { js_Value v; int i; scope = jsR_newenvironment(J, jsV_newobject(J, JS_COBJECT, NULL), scope); jsR_savescope(J, scope); if (F->arguments) { js_newobject(J); if (!J->strict) { js_currentfunction(J); js_defproperty(J, -2, "callee", JS_DONTENUM); } js_pushnumber(J, n); js_defproperty(J, -2, "length", JS_DONTENUM); for (i = 0; i < n; ++i) { js_copy(J, i + 1); js_setindex(J, -2, i); } js_initvar(J, "arguments", -1); js_pop(J, 1); } for (i = 0; i < F->numparams; ++i) { if (i < n) js_initvar(J, F->vartab[i], i + 1); else { js_pushundefined(J); js_initvar(J, F->vartab[i], -1); js_pop(J, 1); } } js_pop(J, n); jsR_run(J, F); v = *stackidx(J, -1); TOP = --BOT; /* clear stack */ js_pushvalue(J, v); jsR_restorescope(J); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,727
static void jsR_callscript(js_State *J, int n, js_Function *F, js_Environment *scope) { js_Value v; if (scope) jsR_savescope(J, scope); js_pop(J, n); jsR_run(J, F); v = *stackidx(J, -1); TOP = --BOT; /* clear stack */ js_pushvalue(J, v); if (scope) jsR_restorescope(J); }
Overflow
0
static void jsR_callscript(js_State *J, int n, js_Function *F, js_Environment *scope) { js_Value v; if (scope) jsR_savescope(J, scope); js_pop(J, n); jsR_run(J, F); v = *stackidx(J, -1); TOP = --BOT; /* clear stack */ js_pushvalue(J, v); if (scope) jsR_restorescope(J); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,728
static void jsR_defproperty(js_State *J, js_Object *obj, const char *name, int atts, js_Value *value, js_Object *getter, js_Object *setter) { js_Property *ref; int k; if (obj->type == JS_CARRAY) { if (!strcmp(name, "length")) goto readonly; } else if (obj->type == JS_CSTRING) { if (!strcmp(name, "length")) goto readonly; if (js_isarrayindex(J, name, &k)) if (js_runeat(J, obj->u.s.string, k)) goto readonly; } else if (obj->type == JS_CREGEXP) { if (!strcmp(name, "source")) goto readonly; if (!strcmp(name, "global")) goto readonly; if (!strcmp(name, "ignoreCase")) goto readonly; if (!strcmp(name, "multiline")) goto readonly; if (!strcmp(name, "lastIndex")) goto readonly; } else if (obj->type == JS_CUSERDATA) { if (obj->u.user.put && obj->u.user.put(J, obj->u.user.data, name)) return; } ref = jsV_setproperty(J, obj, name); if (ref) { if (value) { if (!(ref->atts & JS_READONLY)) ref->value = *value; else if (J->strict) js_typeerror(J, "'%s' is read-only", name); } if (getter) { if (!(ref->atts & JS_DONTCONF)) ref->getter = getter; else if (J->strict) js_typeerror(J, "'%s' is non-configurable", name); } if (setter) { if (!(ref->atts & JS_DONTCONF)) ref->setter = setter; else if (J->strict) js_typeerror(J, "'%s' is non-configurable", name); } ref->atts |= atts; } return; readonly: if (J->strict) js_typeerror(J, "'%s' is read-only or non-configurable", name); }
Overflow
0
static void jsR_defproperty(js_State *J, js_Object *obj, const char *name, int atts, js_Value *value, js_Object *getter, js_Object *setter) { js_Property *ref; int k; if (obj->type == JS_CARRAY) { if (!strcmp(name, "length")) goto readonly; } else if (obj->type == JS_CSTRING) { if (!strcmp(name, "length")) goto readonly; if (js_isarrayindex(J, name, &k)) if (js_runeat(J, obj->u.s.string, k)) goto readonly; } else if (obj->type == JS_CREGEXP) { if (!strcmp(name, "source")) goto readonly; if (!strcmp(name, "global")) goto readonly; if (!strcmp(name, "ignoreCase")) goto readonly; if (!strcmp(name, "multiline")) goto readonly; if (!strcmp(name, "lastIndex")) goto readonly; } else if (obj->type == JS_CUSERDATA) { if (obj->u.user.put && obj->u.user.put(J, obj->u.user.data, name)) return; } ref = jsV_setproperty(J, obj, name); if (ref) { if (value) { if (!(ref->atts & JS_READONLY)) ref->value = *value; else if (J->strict) js_typeerror(J, "'%s' is read-only", name); } if (getter) { if (!(ref->atts & JS_DONTCONF)) ref->getter = getter; else if (J->strict) js_typeerror(J, "'%s' is non-configurable", name); } if (setter) { if (!(ref->atts & JS_DONTCONF)) ref->setter = setter; else if (J->strict) js_typeerror(J, "'%s' is non-configurable", name); } ref->atts |= atts; } return; readonly: if (J->strict) js_typeerror(J, "'%s' is read-only or non-configurable", name); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,729
static int jsR_delproperty(js_State *J, js_Object *obj, const char *name) { js_Property *ref; int k; if (obj->type == JS_CARRAY) { if (!strcmp(name, "length")) goto dontconf; } else if (obj->type == JS_CSTRING) { if (!strcmp(name, "length")) goto dontconf; if (js_isarrayindex(J, name, &k)) if (js_runeat(J, obj->u.s.string, k)) goto dontconf; } else if (obj->type == JS_CREGEXP) { if (!strcmp(name, "source")) goto dontconf; if (!strcmp(name, "global")) goto dontconf; if (!strcmp(name, "ignoreCase")) goto dontconf; if (!strcmp(name, "multiline")) goto dontconf; if (!strcmp(name, "lastIndex")) goto dontconf; } else if (obj->type == JS_CUSERDATA) { if (obj->u.user.delete && obj->u.user.delete(J, obj->u.user.data, name)) return 1; } ref = jsV_getownproperty(J, obj, name); if (ref) { if (ref->atts & JS_DONTCONF) goto dontconf; jsV_delproperty(J, obj, name); } return 1; dontconf: if (J->strict) js_typeerror(J, "'%s' is non-configurable", name); return 0; }
Overflow
0
static int jsR_delproperty(js_State *J, js_Object *obj, const char *name) { js_Property *ref; int k; if (obj->type == JS_CARRAY) { if (!strcmp(name, "length")) goto dontconf; } else if (obj->type == JS_CSTRING) { if (!strcmp(name, "length")) goto dontconf; if (js_isarrayindex(J, name, &k)) if (js_runeat(J, obj->u.s.string, k)) goto dontconf; } else if (obj->type == JS_CREGEXP) { if (!strcmp(name, "source")) goto dontconf; if (!strcmp(name, "global")) goto dontconf; if (!strcmp(name, "ignoreCase")) goto dontconf; if (!strcmp(name, "multiline")) goto dontconf; if (!strcmp(name, "lastIndex")) goto dontconf; } else if (obj->type == JS_CUSERDATA) { if (obj->u.user.delete && obj->u.user.delete(J, obj->u.user.data, name)) return 1; } ref = jsV_getownproperty(J, obj, name); if (ref) { if (ref->atts & JS_DONTCONF) goto dontconf; jsV_delproperty(J, obj, name); } return 1; dontconf: if (J->strict) js_typeerror(J, "'%s' is non-configurable", name); return 0; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,730
static void jsR_dumpstack(js_State *J) { int i; printf("stack {\n"); for (i = 0; i < TOP; ++i) { putchar(i == BOT ? '>' : ' '); printf("% 4d: ", i); js_dumpvalue(J, STACK[i]); putchar('\n'); } printf("}\n"); }
Overflow
0
static void jsR_dumpstack(js_State *J) { int i; printf("stack {\n"); for (i = 0; i < TOP; ++i) { putchar(i == BOT ? '>' : ' '); printf("% 4d: ", i); js_dumpvalue(J, STACK[i]); putchar('\n'); } printf("}\n"); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,731
static void jsR_getproperty(js_State *J, js_Object *obj, const char *name) { if (!jsR_hasproperty(J, obj, name)) js_pushundefined(J); }
Overflow
0
static void jsR_getproperty(js_State *J, js_Object *obj, const char *name) { if (!jsR_hasproperty(J, obj, name)) js_pushundefined(J); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,732
js_Environment *jsR_newenvironment(js_State *J, js_Object *vars, js_Environment *outer) { js_Environment *E = js_malloc(J, sizeof *E); E->gcmark = 0; E->gcnext = J->gcenv; J->gcenv = E; ++J->gccounter; E->outer = outer; E->variables = vars; return E; }
Overflow
0
js_Environment *jsR_newenvironment(js_State *J, js_Object *vars, js_Environment *outer) { js_Environment *E = js_malloc(J, sizeof *E); E->gcmark = 0; E->gcnext = J->gcenv; J->gcenv = E; ++J->gccounter; E->outer = outer; E->variables = vars; return E; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,733
static void jsR_run(js_State *J, js_Function *F) { js_Function **FT = F->funtab; double *NT = F->numtab; const char **ST = F->strtab; js_Instruction *pcstart = F->code; js_Instruction *pc = F->code; enum js_OpCode opcode; int offset; const char *str; js_Object *obj; double x, y; unsigned int ux, uy; int ix, iy, okay; int b; while (1) { if (J->gccounter > JS_GCLIMIT) { J->gccounter = 0; js_gc(J, 0); } opcode = *pc++; switch (opcode) { case OP_POP: js_pop(J, 1); break; case OP_DUP: js_dup(J); break; case OP_DUP2: js_dup2(J); break; case OP_ROT2: js_rot2(J); break; case OP_ROT3: js_rot3(J); break; case OP_ROT4: js_rot4(J); break; case OP_NUMBER_0: js_pushnumber(J, 0); break; case OP_NUMBER_1: js_pushnumber(J, 1); break; case OP_NUMBER_POS: js_pushnumber(J, *pc++); break; case OP_NUMBER_NEG: js_pushnumber(J, -(*pc++)); break; case OP_NUMBER: js_pushnumber(J, NT[*pc++]); break; case OP_STRING: js_pushliteral(J, ST[*pc++]); break; case OP_CLOSURE: js_newfunction(J, FT[*pc++], J->E); break; case OP_NEWOBJECT: js_newobject(J); break; case OP_NEWARRAY: js_newarray(J); break; case OP_NEWREGEXP: js_newregexp(J, ST[pc[0]], pc[1]); pc += 2; break; case OP_UNDEF: js_pushundefined(J); break; case OP_NULL: js_pushnull(J); break; case OP_TRUE: js_pushboolean(J, 1); break; case OP_FALSE: js_pushboolean(J, 0); break; case OP_THIS: js_copy(J, 0); break; case OP_GLOBAL: js_pushobject(J, J->G); break; case OP_CURRENT: js_currentfunction(J); break; case OP_INITLOCAL: STACK[BOT + *pc++] = STACK[--TOP]; break; case OP_GETLOCAL: CHECKSTACK(1); STACK[TOP++] = STACK[BOT + *pc++]; break; case OP_SETLOCAL: STACK[BOT + *pc++] = STACK[TOP-1]; break; case OP_DELLOCAL: ++pc; js_pushboolean(J, 0); break; case OP_INITVAR: js_initvar(J, ST[*pc++], -1); js_pop(J, 1); break; case OP_DEFVAR: js_defvar(J, ST[*pc++]); break; case OP_GETVAR: str = ST[*pc++]; if (!js_hasvar(J, str)) js_referenceerror(J, "'%s' is not defined", str); break; case OP_HASVAR: if (!js_hasvar(J, ST[*pc++])) js_pushundefined(J); break; case OP_SETVAR: js_setvar(J, ST[*pc++]); break; case OP_DELVAR: b = js_delvar(J, ST[*pc++]); js_pushboolean(J, b); break; case OP_IN: str = js_tostring(J, -2); if (!js_isobject(J, -1)) js_typeerror(J, "operand to 'in' is not an object"); b = js_hasproperty(J, -1, str); js_pop(J, 2 + b); js_pushboolean(J, b); break; case OP_INITPROP: obj = js_toobject(J, -3); str = js_tostring(J, -2); jsR_setproperty(J, obj, str); js_pop(J, 2); break; case OP_INITGETTER: obj = js_toobject(J, -3); str = js_tostring(J, -2); jsR_defproperty(J, obj, str, 0, NULL, jsR_tofunction(J, -1), NULL); js_pop(J, 2); break; case OP_INITSETTER: obj = js_toobject(J, -3); str = js_tostring(J, -2); jsR_defproperty(J, obj, str, 0, NULL, NULL, jsR_tofunction(J, -1)); js_pop(J, 2); break; case OP_GETPROP: str = js_tostring(J, -1); obj = js_toobject(J, -2); jsR_getproperty(J, obj, str); js_rot3pop2(J); break; case OP_GETPROP_S: str = ST[*pc++]; obj = js_toobject(J, -1); jsR_getproperty(J, obj, str); js_rot2pop1(J); break; case OP_SETPROP: str = js_tostring(J, -2); obj = js_toobject(J, -3); jsR_setproperty(J, obj, str); js_rot3pop2(J); break; case OP_SETPROP_S: str = ST[*pc++]; obj = js_toobject(J, -2); jsR_setproperty(J, obj, str); js_rot2pop1(J); break; case OP_DELPROP: str = js_tostring(J, -1); obj = js_toobject(J, -2); b = jsR_delproperty(J, obj, str); js_pop(J, 2); js_pushboolean(J, b); break; case OP_DELPROP_S: str = ST[*pc++]; obj = js_toobject(J, -1); b = jsR_delproperty(J, obj, str); js_pop(J, 1); js_pushboolean(J, b); break; case OP_ITERATOR: if (!js_isundefined(J, -1) && !js_isnull(J, -1)) { obj = jsV_newiterator(J, js_toobject(J, -1), 0); js_pop(J, 1); js_pushobject(J, obj); } break; case OP_NEXTITER: obj = js_toobject(J, -1); str = jsV_nextiterator(J, obj); if (str) { js_pushliteral(J, str); js_pushboolean(J, 1); } else { js_pop(J, 1); js_pushboolean(J, 0); } break; /* Function calls */ case OP_EVAL: js_eval(J); break; case OP_CALL: js_call(J, *pc++); break; case OP_NEW: js_construct(J, *pc++); break; /* Unary operators */ case OP_TYPEOF: str = js_typeof(J, -1); js_pop(J, 1); js_pushliteral(J, str); break; case OP_POS: x = js_tonumber(J, -1); js_pop(J, 1); js_pushnumber(J, x); break; case OP_NEG: x = js_tonumber(J, -1); js_pop(J, 1); js_pushnumber(J, -x); break; case OP_BITNOT: ix = js_toint32(J, -1); js_pop(J, 1); js_pushnumber(J, ~ix); break; case OP_LOGNOT: b = js_toboolean(J, -1); js_pop(J, 1); js_pushboolean(J, !b); break; case OP_INC: x = js_tonumber(J, -1); js_pop(J, 1); js_pushnumber(J, x + 1); break; case OP_DEC: x = js_tonumber(J, -1); js_pop(J, 1); js_pushnumber(J, x - 1); break; case OP_POSTINC: x = js_tonumber(J, -1); js_pop(J, 1); js_pushnumber(J, x + 1); js_pushnumber(J, x); break; case OP_POSTDEC: x = js_tonumber(J, -1); js_pop(J, 1); js_pushnumber(J, x - 1); js_pushnumber(J, x); break; /* Multiplicative operators */ case OP_MUL: x = js_tonumber(J, -2); y = js_tonumber(J, -1); js_pop(J, 2); js_pushnumber(J, x * y); break; case OP_DIV: x = js_tonumber(J, -2); y = js_tonumber(J, -1); js_pop(J, 2); js_pushnumber(J, x / y); break; case OP_MOD: x = js_tonumber(J, -2); y = js_tonumber(J, -1); js_pop(J, 2); js_pushnumber(J, fmod(x, y)); break; /* Additive operators */ case OP_ADD: js_concat(J); break; case OP_SUB: x = js_tonumber(J, -2); y = js_tonumber(J, -1); js_pop(J, 2); js_pushnumber(J, x - y); break; /* Shift operators */ case OP_SHL: ix = js_toint32(J, -2); uy = js_touint32(J, -1); js_pop(J, 2); js_pushnumber(J, ix << (uy & 0x1F)); break; case OP_SHR: ix = js_toint32(J, -2); uy = js_touint32(J, -1); js_pop(J, 2); js_pushnumber(J, ix >> (uy & 0x1F)); break; case OP_USHR: ux = js_touint32(J, -2); uy = js_touint32(J, -1); js_pop(J, 2); js_pushnumber(J, ux >> (uy & 0x1F)); break; /* Relational operators */ case OP_LT: b = js_compare(J, &okay); js_pop(J, 2); js_pushboolean(J, okay && b < 0); break; case OP_GT: b = js_compare(J, &okay); js_pop(J, 2); js_pushboolean(J, okay && b > 0); break; case OP_LE: b = js_compare(J, &okay); js_pop(J, 2); js_pushboolean(J, okay && b <= 0); break; case OP_GE: b = js_compare(J, &okay); js_pop(J, 2); js_pushboolean(J, okay && b >= 0); break; case OP_INSTANCEOF: b = js_instanceof(J); js_pop(J, 2); js_pushboolean(J, b); break; /* Equality */ case OP_EQ: b = js_equal(J); js_pop(J, 2); js_pushboolean(J, b); break; case OP_NE: b = js_equal(J); js_pop(J, 2); js_pushboolean(J, !b); break; case OP_STRICTEQ: b = js_strictequal(J); js_pop(J, 2); js_pushboolean(J, b); break; case OP_STRICTNE: b = js_strictequal(J); js_pop(J, 2); js_pushboolean(J, !b); break; case OP_JCASE: offset = *pc++; b = js_strictequal(J); if (b) { js_pop(J, 2); pc = pcstart + offset; } else { js_pop(J, 1); } break; /* Binary bitwise operators */ case OP_BITAND: ix = js_toint32(J, -2); iy = js_toint32(J, -1); js_pop(J, 2); js_pushnumber(J, ix & iy); break; case OP_BITXOR: ix = js_toint32(J, -2); iy = js_toint32(J, -1); js_pop(J, 2); js_pushnumber(J, ix ^ iy); break; case OP_BITOR: ix = js_toint32(J, -2); iy = js_toint32(J, -1); js_pop(J, 2); js_pushnumber(J, ix | iy); break; /* Try and Catch */ case OP_THROW: js_throw(J); case OP_TRY: offset = *pc++; if (js_trypc(J, pc)) { pc = J->trybuf[J->trytop].pc; } else { pc = pcstart + offset; } break; case OP_ENDTRY: js_endtry(J); break; case OP_CATCH: str = ST[*pc++]; obj = jsV_newobject(J, JS_COBJECT, NULL); js_pushobject(J, obj); js_rot2(J); js_setproperty(J, -2, str); J->E = jsR_newenvironment(J, obj, J->E); js_pop(J, 1); break; case OP_ENDCATCH: J->E = J->E->outer; break; /* With */ case OP_WITH: obj = js_toobject(J, -1); J->E = jsR_newenvironment(J, obj, J->E); js_pop(J, 1); break; case OP_ENDWITH: J->E = J->E->outer; break; /* Branching */ case OP_DEBUGGER: js_trap(J, (int)(pc - pcstart) - 1); break; case OP_JUMP: pc = pcstart + *pc; break; case OP_JTRUE: offset = *pc++; b = js_toboolean(J, -1); js_pop(J, 1); if (b) pc = pcstart + offset; break; case OP_JFALSE: offset = *pc++; b = js_toboolean(J, -1); js_pop(J, 1); if (!b) pc = pcstart + offset; break; case OP_RETURN: return; case OP_LINE: J->trace[J->tracetop].line = *pc++; break; } } }
Overflow
0
static void jsR_run(js_State *J, js_Function *F) { js_Function **FT = F->funtab; double *NT = F->numtab; const char **ST = F->strtab; js_Instruction *pcstart = F->code; js_Instruction *pc = F->code; enum js_OpCode opcode; int offset; const char *str; js_Object *obj; double x, y; unsigned int ux, uy; int ix, iy, okay; int b; while (1) { if (J->gccounter > JS_GCLIMIT) { J->gccounter = 0; js_gc(J, 0); } opcode = *pc++; switch (opcode) { case OP_POP: js_pop(J, 1); break; case OP_DUP: js_dup(J); break; case OP_DUP2: js_dup2(J); break; case OP_ROT2: js_rot2(J); break; case OP_ROT3: js_rot3(J); break; case OP_ROT4: js_rot4(J); break; case OP_NUMBER_0: js_pushnumber(J, 0); break; case OP_NUMBER_1: js_pushnumber(J, 1); break; case OP_NUMBER_POS: js_pushnumber(J, *pc++); break; case OP_NUMBER_NEG: js_pushnumber(J, -(*pc++)); break; case OP_NUMBER: js_pushnumber(J, NT[*pc++]); break; case OP_STRING: js_pushliteral(J, ST[*pc++]); break; case OP_CLOSURE: js_newfunction(J, FT[*pc++], J->E); break; case OP_NEWOBJECT: js_newobject(J); break; case OP_NEWARRAY: js_newarray(J); break; case OP_NEWREGEXP: js_newregexp(J, ST[pc[0]], pc[1]); pc += 2; break; case OP_UNDEF: js_pushundefined(J); break; case OP_NULL: js_pushnull(J); break; case OP_TRUE: js_pushboolean(J, 1); break; case OP_FALSE: js_pushboolean(J, 0); break; case OP_THIS: js_copy(J, 0); break; case OP_GLOBAL: js_pushobject(J, J->G); break; case OP_CURRENT: js_currentfunction(J); break; case OP_INITLOCAL: STACK[BOT + *pc++] = STACK[--TOP]; break; case OP_GETLOCAL: CHECKSTACK(1); STACK[TOP++] = STACK[BOT + *pc++]; break; case OP_SETLOCAL: STACK[BOT + *pc++] = STACK[TOP-1]; break; case OP_DELLOCAL: ++pc; js_pushboolean(J, 0); break; case OP_INITVAR: js_initvar(J, ST[*pc++], -1); js_pop(J, 1); break; case OP_DEFVAR: js_defvar(J, ST[*pc++]); break; case OP_GETVAR: str = ST[*pc++]; if (!js_hasvar(J, str)) js_referenceerror(J, "'%s' is not defined", str); break; case OP_HASVAR: if (!js_hasvar(J, ST[*pc++])) js_pushundefined(J); break; case OP_SETVAR: js_setvar(J, ST[*pc++]); break; case OP_DELVAR: b = js_delvar(J, ST[*pc++]); js_pushboolean(J, b); break; case OP_IN: str = js_tostring(J, -2); if (!js_isobject(J, -1)) js_typeerror(J, "operand to 'in' is not an object"); b = js_hasproperty(J, -1, str); js_pop(J, 2 + b); js_pushboolean(J, b); break; case OP_INITPROP: obj = js_toobject(J, -3); str = js_tostring(J, -2); jsR_setproperty(J, obj, str); js_pop(J, 2); break; case OP_INITGETTER: obj = js_toobject(J, -3); str = js_tostring(J, -2); jsR_defproperty(J, obj, str, 0, NULL, jsR_tofunction(J, -1), NULL); js_pop(J, 2); break; case OP_INITSETTER: obj = js_toobject(J, -3); str = js_tostring(J, -2); jsR_defproperty(J, obj, str, 0, NULL, NULL, jsR_tofunction(J, -1)); js_pop(J, 2); break; case OP_GETPROP: str = js_tostring(J, -1); obj = js_toobject(J, -2); jsR_getproperty(J, obj, str); js_rot3pop2(J); break; case OP_GETPROP_S: str = ST[*pc++]; obj = js_toobject(J, -1); jsR_getproperty(J, obj, str); js_rot2pop1(J); break; case OP_SETPROP: str = js_tostring(J, -2); obj = js_toobject(J, -3); jsR_setproperty(J, obj, str); js_rot3pop2(J); break; case OP_SETPROP_S: str = ST[*pc++]; obj = js_toobject(J, -2); jsR_setproperty(J, obj, str); js_rot2pop1(J); break; case OP_DELPROP: str = js_tostring(J, -1); obj = js_toobject(J, -2); b = jsR_delproperty(J, obj, str); js_pop(J, 2); js_pushboolean(J, b); break; case OP_DELPROP_S: str = ST[*pc++]; obj = js_toobject(J, -1); b = jsR_delproperty(J, obj, str); js_pop(J, 1); js_pushboolean(J, b); break; case OP_ITERATOR: if (!js_isundefined(J, -1) && !js_isnull(J, -1)) { obj = jsV_newiterator(J, js_toobject(J, -1), 0); js_pop(J, 1); js_pushobject(J, obj); } break; case OP_NEXTITER: obj = js_toobject(J, -1); str = jsV_nextiterator(J, obj); if (str) { js_pushliteral(J, str); js_pushboolean(J, 1); } else { js_pop(J, 1); js_pushboolean(J, 0); } break; /* Function calls */ case OP_EVAL: js_eval(J); break; case OP_CALL: js_call(J, *pc++); break; case OP_NEW: js_construct(J, *pc++); break; /* Unary operators */ case OP_TYPEOF: str = js_typeof(J, -1); js_pop(J, 1); js_pushliteral(J, str); break; case OP_POS: x = js_tonumber(J, -1); js_pop(J, 1); js_pushnumber(J, x); break; case OP_NEG: x = js_tonumber(J, -1); js_pop(J, 1); js_pushnumber(J, -x); break; case OP_BITNOT: ix = js_toint32(J, -1); js_pop(J, 1); js_pushnumber(J, ~ix); break; case OP_LOGNOT: b = js_toboolean(J, -1); js_pop(J, 1); js_pushboolean(J, !b); break; case OP_INC: x = js_tonumber(J, -1); js_pop(J, 1); js_pushnumber(J, x + 1); break; case OP_DEC: x = js_tonumber(J, -1); js_pop(J, 1); js_pushnumber(J, x - 1); break; case OP_POSTINC: x = js_tonumber(J, -1); js_pop(J, 1); js_pushnumber(J, x + 1); js_pushnumber(J, x); break; case OP_POSTDEC: x = js_tonumber(J, -1); js_pop(J, 1); js_pushnumber(J, x - 1); js_pushnumber(J, x); break; /* Multiplicative operators */ case OP_MUL: x = js_tonumber(J, -2); y = js_tonumber(J, -1); js_pop(J, 2); js_pushnumber(J, x * y); break; case OP_DIV: x = js_tonumber(J, -2); y = js_tonumber(J, -1); js_pop(J, 2); js_pushnumber(J, x / y); break; case OP_MOD: x = js_tonumber(J, -2); y = js_tonumber(J, -1); js_pop(J, 2); js_pushnumber(J, fmod(x, y)); break; /* Additive operators */ case OP_ADD: js_concat(J); break; case OP_SUB: x = js_tonumber(J, -2); y = js_tonumber(J, -1); js_pop(J, 2); js_pushnumber(J, x - y); break; /* Shift operators */ case OP_SHL: ix = js_toint32(J, -2); uy = js_touint32(J, -1); js_pop(J, 2); js_pushnumber(J, ix << (uy & 0x1F)); break; case OP_SHR: ix = js_toint32(J, -2); uy = js_touint32(J, -1); js_pop(J, 2); js_pushnumber(J, ix >> (uy & 0x1F)); break; case OP_USHR: ux = js_touint32(J, -2); uy = js_touint32(J, -1); js_pop(J, 2); js_pushnumber(J, ux >> (uy & 0x1F)); break; /* Relational operators */ case OP_LT: b = js_compare(J, &okay); js_pop(J, 2); js_pushboolean(J, okay && b < 0); break; case OP_GT: b = js_compare(J, &okay); js_pop(J, 2); js_pushboolean(J, okay && b > 0); break; case OP_LE: b = js_compare(J, &okay); js_pop(J, 2); js_pushboolean(J, okay && b <= 0); break; case OP_GE: b = js_compare(J, &okay); js_pop(J, 2); js_pushboolean(J, okay && b >= 0); break; case OP_INSTANCEOF: b = js_instanceof(J); js_pop(J, 2); js_pushboolean(J, b); break; /* Equality */ case OP_EQ: b = js_equal(J); js_pop(J, 2); js_pushboolean(J, b); break; case OP_NE: b = js_equal(J); js_pop(J, 2); js_pushboolean(J, !b); break; case OP_STRICTEQ: b = js_strictequal(J); js_pop(J, 2); js_pushboolean(J, b); break; case OP_STRICTNE: b = js_strictequal(J); js_pop(J, 2); js_pushboolean(J, !b); break; case OP_JCASE: offset = *pc++; b = js_strictequal(J); if (b) { js_pop(J, 2); pc = pcstart + offset; } else { js_pop(J, 1); } break; /* Binary bitwise operators */ case OP_BITAND: ix = js_toint32(J, -2); iy = js_toint32(J, -1); js_pop(J, 2); js_pushnumber(J, ix & iy); break; case OP_BITXOR: ix = js_toint32(J, -2); iy = js_toint32(J, -1); js_pop(J, 2); js_pushnumber(J, ix ^ iy); break; case OP_BITOR: ix = js_toint32(J, -2); iy = js_toint32(J, -1); js_pop(J, 2); js_pushnumber(J, ix | iy); break; /* Try and Catch */ case OP_THROW: js_throw(J); case OP_TRY: offset = *pc++; if (js_trypc(J, pc)) { pc = J->trybuf[J->trytop].pc; } else { pc = pcstart + offset; } break; case OP_ENDTRY: js_endtry(J); break; case OP_CATCH: str = ST[*pc++]; obj = jsV_newobject(J, JS_COBJECT, NULL); js_pushobject(J, obj); js_rot2(J); js_setproperty(J, -2, str); J->E = jsR_newenvironment(J, obj, J->E); js_pop(J, 1); break; case OP_ENDCATCH: J->E = J->E->outer; break; /* With */ case OP_WITH: obj = js_toobject(J, -1); J->E = jsR_newenvironment(J, obj, J->E); js_pop(J, 1); break; case OP_ENDWITH: J->E = J->E->outer; break; /* Branching */ case OP_DEBUGGER: js_trap(J, (int)(pc - pcstart) - 1); break; case OP_JUMP: pc = pcstart + *pc; break; case OP_JTRUE: offset = *pc++; b = js_toboolean(J, -1); js_pop(J, 1); if (b) pc = pcstart + offset; break; case OP_JFALSE: offset = *pc++; b = js_toboolean(J, -1); js_pop(J, 1); if (!b) pc = pcstart + offset; break; case OP_RETURN: return; case OP_LINE: J->trace[J->tracetop].line = *pc++; break; } } }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,734
static js_Object *jsR_tofunction(js_State *J, int idx) { js_Value *v = stackidx(J, idx); if (v->type == JS_TUNDEFINED || v->type == JS_TNULL) return NULL; if (v->type == JS_TOBJECT) if (v->u.object->type == JS_CFUNCTION || v->u.object->type == JS_CCFUNCTION) return v->u.object; js_typeerror(J, "not a function"); }
Overflow
0
static js_Object *jsR_tofunction(js_State *J, int idx) { js_Value *v = stackidx(J, idx); if (v->type == JS_TUNDEFINED || v->type == JS_TNULL) return NULL; if (v->type == JS_TOBJECT) if (v->u.object->type == JS_CFUNCTION || v->u.object->type == JS_CCFUNCTION) return v->u.object; js_typeerror(J, "not a function"); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,735
void js_construct(js_State *J, int n) { js_Object *obj; js_Object *prototype; js_Object *newobj; if (!js_iscallable(J, -n-1)) js_typeerror(J, "called object is not a function"); obj = js_toobject(J, -n-1); /* built-in constructors create their own objects, give them a 'null' this */ if (obj->type == JS_CCFUNCTION && obj->u.c.constructor) { int savebot = BOT; js_pushnull(J); if (n > 0) js_rot(J, n + 1); BOT = TOP - n - 1; jsR_pushtrace(J, obj->u.c.name, "native", 0); jsR_callcfunction(J, n, obj->u.c.length, obj->u.c.constructor); --J->tracetop; BOT = savebot; return; } /* extract the function object's prototype property */ js_getproperty(J, -n - 1, "prototype"); if (js_isobject(J, -1)) prototype = js_toobject(J, -1); else prototype = J->Object_prototype; js_pop(J, 1); /* create a new object with above prototype, and shift it into the 'this' slot */ newobj = jsV_newobject(J, JS_COBJECT, prototype); js_pushobject(J, newobj); if (n > 0) js_rot(J, n + 1); /* call the function */ js_call(J, n); /* if result is not an object, return the original object we created */ if (!js_isobject(J, -1)) { js_pop(J, 1); js_pushobject(J, newobj); } }
Overflow
0
void js_construct(js_State *J, int n) { js_Object *obj; js_Object *prototype; js_Object *newobj; if (!js_iscallable(J, -n-1)) js_typeerror(J, "called object is not a function"); obj = js_toobject(J, -n-1); /* built-in constructors create their own objects, give them a 'null' this */ if (obj->type == JS_CCFUNCTION && obj->u.c.constructor) { int savebot = BOT; js_pushnull(J); if (n > 0) js_rot(J, n + 1); BOT = TOP - n - 1; jsR_pushtrace(J, obj->u.c.name, "native", 0); jsR_callcfunction(J, n, obj->u.c.length, obj->u.c.constructor); --J->tracetop; BOT = savebot; return; } /* extract the function object's prototype property */ js_getproperty(J, -n - 1, "prototype"); if (js_isobject(J, -1)) prototype = js_toobject(J, -1); else prototype = J->Object_prototype; js_pop(J, 1); /* create a new object with above prototype, and shift it into the 'this' slot */ newobj = jsV_newobject(J, JS_COBJECT, prototype); js_pushobject(J, newobj); if (n > 0) js_rot(J, n + 1); /* call the function */ js_call(J, n); /* if result is not an object, return the original object we created */ if (!js_isobject(J, -1)) { js_pop(J, 1); js_pushobject(J, newobj); } }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,736
void js_defaccessor(js_State *J, int idx, const char *name, int atts) { jsR_defproperty(J, js_toobject(J, idx), name, atts, NULL, jsR_tofunction(J, -2), jsR_tofunction(J, -1)); js_pop(J, 2); }
Overflow
0
void js_defaccessor(js_State *J, int idx, const char *name, int atts) { jsR_defproperty(J, js_toobject(J, idx), name, atts, NULL, jsR_tofunction(J, -2), jsR_tofunction(J, -1)); js_pop(J, 2); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,737
void js_defproperty(js_State *J, int idx, const char *name, int atts) { jsR_defproperty(J, js_toobject(J, idx), name, atts, stackidx(J, -1), NULL, NULL); js_pop(J, 1); }
Overflow
0
void js_defproperty(js_State *J, int idx, const char *name, int atts) { jsR_defproperty(J, js_toobject(J, idx), name, atts, stackidx(J, -1), NULL, NULL); js_pop(J, 1); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,738
static void js_defvar(js_State *J, const char *name) { jsR_defproperty(J, J->E->variables, name, JS_DONTENUM | JS_DONTCONF, NULL, NULL, NULL); }
Overflow
0
static void js_defvar(js_State *J, const char *name) { jsR_defproperty(J, J->E->variables, name, JS_DONTENUM | JS_DONTCONF, NULL, NULL, NULL); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,739
void js_delregistry(js_State *J, const char *name) { jsR_delproperty(J, J->R, name); }
Overflow
0
void js_delregistry(js_State *J, const char *name) { jsR_delproperty(J, J->R, name); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,740
static int js_delvar(js_State *J, const char *name) { js_Environment *E = J->E; do { js_Property *ref = jsV_getownproperty(J, E->variables, name); if (ref) { if (ref->atts & JS_DONTCONF) { if (J->strict) js_typeerror(J, "'%s' is non-configurable", name); return 0; } jsV_delproperty(J, E->variables, name); return 1; } E = E->outer; } while (E); return jsR_delproperty(J, J->G, name); }
Overflow
0
static int js_delvar(js_State *J, const char *name) { js_Environment *E = J->E; do { js_Property *ref = jsV_getownproperty(J, E->variables, name); if (ref) { if (ref->atts & JS_DONTCONF) { if (J->strict) js_typeerror(J, "'%s' is non-configurable", name); return 0; } jsV_delproperty(J, E->variables, name); return 1; } E = E->outer; } while (E); return jsR_delproperty(J, J->G, name); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,741
void js_dup(js_State *J) { CHECKSTACK(1); STACK[TOP] = STACK[TOP-1]; ++TOP; }
Overflow
0
void js_dup(js_State *J) { CHECKSTACK(1); STACK[TOP] = STACK[TOP-1]; ++TOP; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,742
void js_dup2(js_State *J) { CHECKSTACK(2); STACK[TOP] = STACK[TOP-2]; STACK[TOP+1] = STACK[TOP-1]; TOP += 2; }
Overflow
0
void js_dup2(js_State *J) { CHECKSTACK(2); STACK[TOP] = STACK[TOP-2]; STACK[TOP+1] = STACK[TOP-1]; TOP += 2; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,743
void js_free(js_State *J, void *ptr) { J->alloc(J->actx, ptr, 0); }
Overflow
0
void js_free(js_State *J, void *ptr) { J->alloc(J->actx, ptr, 0); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,744
void js_getproperty(js_State *J, int idx, const char *name) { jsR_getproperty(J, js_toobject(J, idx), name); }
Overflow
0
void js_getproperty(js_State *J, int idx, const char *name) { jsR_getproperty(J, js_toobject(J, idx), name); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,745
void js_getregistry(js_State *J, const char *name) { jsR_getproperty(J, J->R, name); }
Overflow
0
void js_getregistry(js_State *J, const char *name) { jsR_getproperty(J, J->R, name); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,746
int js_gettop(js_State *J) { return TOP - BOT; }
Overflow
0
int js_gettop(js_State *J) { return TOP - BOT; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,747
int js_hasproperty(js_State *J, int idx, const char *name) { return jsR_hasproperty(J, js_toobject(J, idx), name); }
Overflow
0
int js_hasproperty(js_State *J, int idx, const char *name) { return jsR_hasproperty(J, js_toobject(J, idx), name); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,748
static int js_hasvar(js_State *J, const char *name) { js_Environment *E = J->E; do { js_Property *ref = jsV_getproperty(J, E->variables, name); if (ref) { if (ref->getter) { js_pushobject(J, ref->getter); js_pushobject(J, E->variables); js_call(J, 0); } else { js_pushvalue(J, ref->value); } return 1; } E = E->outer; } while (E); return 0; }
Overflow
0
static int js_hasvar(js_State *J, const char *name) { js_Environment *E = J->E; do { js_Property *ref = jsV_getproperty(J, E->variables, name); if (ref) { if (ref->getter) { js_pushobject(J, ref->getter); js_pushobject(J, E->variables); js_call(J, 0); } else { js_pushvalue(J, ref->value); } return 1; } E = E->outer; } while (E); return 0; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,749
static void js_initvar(js_State *J, const char *name, int idx) { jsR_defproperty(J, J->E->variables, name, JS_DONTENUM | JS_DONTCONF, stackidx(J, idx), NULL, NULL); }
Overflow
0
static void js_initvar(js_State *J, const char *name, int idx) { jsR_defproperty(J, J->E->variables, name, JS_DONTENUM | JS_DONTCONF, stackidx(J, idx), NULL, NULL); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,750
int js_isarray(js_State *J, int idx) { js_Value *v = stackidx(J, idx); return v->type == JS_TOBJECT && v->u.object->type == JS_CARRAY; }
Overflow
0
int js_isarray(js_State *J, int idx) { js_Value *v = stackidx(J, idx); return v->type == JS_TOBJECT && v->u.object->type == JS_CARRAY; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,751
int js_isarrayindex(js_State *J, const char *str, int *idx) { char buf[32]; *idx = jsV_numbertointeger(jsV_stringtonumber(J, str)); sprintf(buf, "%u", *idx); return !strcmp(buf, str); }
Overflow
0
int js_isarrayindex(js_State *J, const char *str, int *idx) { char buf[32]; *idx = jsV_numbertointeger(jsV_stringtonumber(J, str)); sprintf(buf, "%u", *idx); return !strcmp(buf, str); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,752
int js_iscoercible(js_State *J, int idx) { js_Value *v = stackidx(J, idx); return v->type != JS_TUNDEFINED && v->type != JS_TNULL; }
Overflow
0
int js_iscoercible(js_State *J, int idx) { js_Value *v = stackidx(J, idx); return v->type != JS_TUNDEFINED && v->type != JS_TNULL; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,753
int js_isdefined(js_State *J, int idx) { return stackidx(J, idx)->type != JS_TUNDEFINED; }
Overflow
0
int js_isdefined(js_State *J, int idx) { return stackidx(J, idx)->type != JS_TUNDEFINED; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,754
int js_isnumber(js_State *J, int idx) { return stackidx(J, idx)->type == JS_TNUMBER; }
Overflow
0
int js_isnumber(js_State *J, int idx) { return stackidx(J, idx)->type == JS_TNUMBER; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,755
int js_isobject(js_State *J, int idx) { return stackidx(J, idx)->type == JS_TOBJECT; }
Overflow
0
int js_isobject(js_State *J, int idx) { return stackidx(J, idx)->type == JS_TOBJECT; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,756
int js_isstring(js_State *J, int idx) { enum js_Type t = stackidx(J, idx)->type; return t == JS_TSHRSTR || t == JS_TLITSTR || t == JS_TMEMSTR; }
Overflow
0
int js_isstring(js_State *J, int idx) { enum js_Type t = stackidx(J, idx)->type; return t == JS_TSHRSTR || t == JS_TLITSTR || t == JS_TMEMSTR; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,757
int js_isuserdata(js_State *J, int idx, const char *tag) { js_Value *v = stackidx(J, idx); if (v->type == JS_TOBJECT && v->u.object->type == JS_CUSERDATA) return !strcmp(tag, v->u.object->u.user.tag); return 0; }
Overflow
0
int js_isuserdata(js_State *J, int idx, const char *tag) { js_Value *v = stackidx(J, idx); if (v->type == JS_TOBJECT && v->u.object->type == JS_CUSERDATA) return !strcmp(tag, v->u.object->u.user.tag); return 0; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,758
void *js_malloc(js_State *J, int size) { void *ptr = J->alloc(J->actx, NULL, size); if (!ptr) js_outofmemory(J); return ptr; }
Overflow
0
void *js_malloc(js_State *J, int size) { void *ptr = J->alloc(J->actx, NULL, size); if (!ptr) js_outofmemory(J); return ptr; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,759
static void js_outofmemory(js_State *J) { STACK[TOP].type = JS_TLITSTR; STACK[TOP].u.litstr = "out of memory"; ++TOP; js_throw(J); }
Overflow
0
static void js_outofmemory(js_State *J) { STACK[TOP].type = JS_TLITSTR; STACK[TOP].u.litstr = "out of memory"; ++TOP; js_throw(J); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,760
int js_pcall(js_State *J, int n) { int savetop = TOP - n - 2; if (js_try(J)) { /* clean up the stack to only hold the error object */ STACK[savetop] = STACK[TOP-1]; TOP = savetop + 1; return 1; } js_call(J, n); js_endtry(J); return 0; }
Overflow
0
int js_pcall(js_State *J, int n) { int savetop = TOP - n - 2; if (js_try(J)) { /* clean up the stack to only hold the error object */ STACK[savetop] = STACK[TOP-1]; TOP = savetop + 1; return 1; } js_call(J, n); js_endtry(J); return 0; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,761
int js_pconstruct(js_State *J, int n) { int savetop = TOP - n - 2; if (js_try(J)) { /* clean up the stack to only hold the error object */ STACK[savetop] = STACK[TOP-1]; TOP = savetop + 1; return 1; } js_construct(J, n); js_endtry(J); return 0; }
Overflow
0
int js_pconstruct(js_State *J, int n) { int savetop = TOP - n - 2; if (js_try(J)) { /* clean up the stack to only hold the error object */ STACK[savetop] = STACK[TOP-1]; TOP = savetop + 1; return 1; } js_construct(J, n); js_endtry(J); return 0; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,762
void js_pop(js_State *J, int n) { TOP -= n; if (TOP < BOT) { TOP = BOT; js_error(J, "stack underflow!"); } }
Overflow
0
void js_pop(js_State *J, int n) { TOP -= n; if (TOP < BOT) { TOP = BOT; js_error(J, "stack underflow!"); } }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,763
void js_pushboolean(js_State *J, int v) { CHECKSTACK(1); STACK[TOP].type = JS_TBOOLEAN; STACK[TOP].u.boolean = !!v; ++TOP; }
Overflow
0
void js_pushboolean(js_State *J, int v) { CHECKSTACK(1); STACK[TOP].type = JS_TBOOLEAN; STACK[TOP].u.boolean = !!v; ++TOP; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,764
void js_pushglobal(js_State *J) { js_pushobject(J, J->G); }
Overflow
0
void js_pushglobal(js_State *J) { js_pushobject(J, J->G); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,765
void js_pushiterator(js_State *J, int idx, int own) { js_pushobject(J, jsV_newiterator(J, js_toobject(J, idx), own)); }
Overflow
0
void js_pushiterator(js_State *J, int idx, int own) { js_pushobject(J, jsV_newiterator(J, js_toobject(J, idx), own)); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,766
void js_pushlstring(js_State *J, const char *v, int n) { CHECKSTACK(1); if (n <= soffsetof(js_Value, type)) { char *s = STACK[TOP].u.shrstr; while (n--) *s++ = *v++; *s = 0; STACK[TOP].type = JS_TSHRSTR; } else { STACK[TOP].type = JS_TMEMSTR; STACK[TOP].u.memstr = jsV_newmemstring(J, v, n); } ++TOP; }
Overflow
0
void js_pushlstring(js_State *J, const char *v, int n) { CHECKSTACK(1); if (n <= soffsetof(js_Value, type)) { char *s = STACK[TOP].u.shrstr; while (n--) *s++ = *v++; *s = 0; STACK[TOP].type = JS_TSHRSTR; } else { STACK[TOP].type = JS_TMEMSTR; STACK[TOP].u.memstr = jsV_newmemstring(J, v, n); } ++TOP; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,767
void js_pushnull(js_State *J) { CHECKSTACK(1); STACK[TOP].type = JS_TNULL; ++TOP; }
Overflow
0
void js_pushnull(js_State *J) { CHECKSTACK(1); STACK[TOP].type = JS_TNULL; ++TOP; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,768
void js_pushnumber(js_State *J, double v) { CHECKSTACK(1); STACK[TOP].type = JS_TNUMBER; STACK[TOP].u.number = v; ++TOP; }
Overflow
0
void js_pushnumber(js_State *J, double v) { CHECKSTACK(1); STACK[TOP].type = JS_TNUMBER; STACK[TOP].u.number = v; ++TOP; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,769
void js_pushobject(js_State *J, js_Object *v) { CHECKSTACK(1); STACK[TOP].type = JS_TOBJECT; STACK[TOP].u.object = v; ++TOP; }
Overflow
0
void js_pushobject(js_State *J, js_Object *v) { CHECKSTACK(1); STACK[TOP].type = JS_TOBJECT; STACK[TOP].u.object = v; ++TOP; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,770
static void js_pushrune(js_State *J, Rune rune) { char buf[UTFmax + 1]; if (rune > 0) { buf[runetochar(buf, &rune)] = 0; js_pushstring(J, buf); } else { js_pushundefined(J); } }
Overflow
0
static void js_pushrune(js_State *J, Rune rune) { char buf[UTFmax + 1]; if (rune > 0) { buf[runetochar(buf, &rune)] = 0; js_pushstring(J, buf); } else { js_pushundefined(J); } }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,771
void js_pushstring(js_State *J, const char *v) { int n = strlen(v); CHECKSTACK(1); if (n <= soffsetof(js_Value, type)) { char *s = STACK[TOP].u.shrstr; while (n--) *s++ = *v++; *s = 0; STACK[TOP].type = JS_TSHRSTR; } else { STACK[TOP].type = JS_TMEMSTR; STACK[TOP].u.memstr = jsV_newmemstring(J, v, n); } ++TOP; }
Overflow
0
void js_pushstring(js_State *J, const char *v) { int n = strlen(v); CHECKSTACK(1); if (n <= soffsetof(js_Value, type)) { char *s = STACK[TOP].u.shrstr; while (n--) *s++ = *v++; *s = 0; STACK[TOP].type = JS_TSHRSTR; } else { STACK[TOP].type = JS_TMEMSTR; STACK[TOP].u.memstr = jsV_newmemstring(J, v, n); } ++TOP; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,772
void js_pushundefinedthis(js_State *J) { if (J->strict) js_pushundefined(J); else js_pushobject(J, J->G); }
Overflow
0
void js_pushundefinedthis(js_State *J) { if (J->strict) js_pushundefined(J); else js_pushobject(J, J->G); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,773
void js_pushvalue(js_State *J, js_Value v) { CHECKSTACK(1); STACK[TOP] = v; ++TOP; }
Overflow
0
void js_pushvalue(js_State *J, js_Value v) { CHECKSTACK(1); STACK[TOP] = v; ++TOP; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,774
void *js_realloc(js_State *J, void *ptr, int size) { ptr = J->alloc(J->actx, ptr, size); if (!ptr) js_outofmemory(J); return ptr; }
Overflow
0
void *js_realloc(js_State *J, void *ptr, int size) { ptr = J->alloc(J->actx, ptr, size); if (!ptr) js_outofmemory(J); return ptr; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,775
const char *js_ref(js_State *J) { js_Value *v = stackidx(J, -1); const char *s; char buf[32]; switch (v->type) { case JS_TUNDEFINED: s = "_Undefined"; break; case JS_TNULL: s = "_Null"; break; case JS_TBOOLEAN: s = v->u.boolean ? "_True" : "_False"; break; case JS_TOBJECT: sprintf(buf, "%p", (void*)v->u.object); s = js_intern(J, buf); break; default: sprintf(buf, "%d", J->nextref++); s = js_intern(J, buf); break; } js_setregistry(J, s); return s; }
Overflow
0
const char *js_ref(js_State *J) { js_Value *v = stackidx(J, -1); const char *s; char buf[32]; switch (v->type) { case JS_TUNDEFINED: s = "_Undefined"; break; case JS_TNULL: s = "_Null"; break; case JS_TBOOLEAN: s = v->u.boolean ? "_True" : "_False"; break; case JS_TOBJECT: sprintf(buf, "%p", (void*)v->u.object); s = js_intern(J, buf); break; default: sprintf(buf, "%d", J->nextref++); s = js_intern(J, buf); break; } js_setregistry(J, s); return s; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,776
void js_remove(js_State *J, int idx) { idx = idx < 0 ? TOP + idx : BOT + idx; if (idx < BOT || idx >= TOP) js_error(J, "stack error!"); for (;idx < TOP - 1; ++idx) STACK[idx] = STACK[idx+1]; --TOP; }
Overflow
0
void js_remove(js_State *J, int idx) { idx = idx < 0 ? TOP + idx : BOT + idx; if (idx < BOT || idx >= TOP) js_error(J, "stack error!"); for (;idx < TOP - 1; ++idx) STACK[idx] = STACK[idx+1]; --TOP; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,777
void js_replace(js_State* J, int idx) { idx = idx < 0 ? TOP + idx : BOT + idx; if (idx < BOT || idx >= TOP) js_error(J, "stack error!"); STACK[idx] = STACK[--TOP]; }
Overflow
0
void js_replace(js_State* J, int idx) { idx = idx < 0 ? TOP + idx : BOT + idx; if (idx < BOT || idx >= TOP) js_error(J, "stack error!"); STACK[idx] = STACK[--TOP]; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,778
void js_rot(js_State *J, int n) { int i; js_Value tmp = STACK[TOP-1]; for (i = 1; i < n; ++i) STACK[TOP-i] = STACK[TOP-i-1]; STACK[TOP-i] = tmp; }
Overflow
0
void js_rot(js_State *J, int n) { int i; js_Value tmp = STACK[TOP-1]; for (i = 1; i < n; ++i) STACK[TOP-i] = STACK[TOP-i-1]; STACK[TOP-i] = tmp; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,779
void js_rot2(js_State *J) { /* A B -> B A */ js_Value tmp = STACK[TOP-1]; /* A B (B) */ STACK[TOP-1] = STACK[TOP-2]; /* A A */ STACK[TOP-2] = tmp; /* B A */ }
Overflow
0
void js_rot2(js_State *J) { /* A B -> B A */ js_Value tmp = STACK[TOP-1]; /* A B (B) */ STACK[TOP-1] = STACK[TOP-2]; /* A A */ STACK[TOP-2] = tmp; /* B A */ }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,780
void js_rot2pop1(js_State *J) { /* A B -> B */ STACK[TOP-2] = STACK[TOP-1]; --TOP; }
Overflow
0
void js_rot2pop1(js_State *J) { /* A B -> B */ STACK[TOP-2] = STACK[TOP-1]; --TOP; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,781
void js_rot3(js_State *J) { /* A B C -> C A B */ js_Value tmp = STACK[TOP-1]; /* A B C (C) */ STACK[TOP-1] = STACK[TOP-2]; /* A B B */ STACK[TOP-2] = STACK[TOP-3]; /* A A B */ STACK[TOP-3] = tmp; /* C A B */ }
Overflow
0
void js_rot3(js_State *J) { /* A B C -> C A B */ js_Value tmp = STACK[TOP-1]; /* A B C (C) */ STACK[TOP-1] = STACK[TOP-2]; /* A B B */ STACK[TOP-2] = STACK[TOP-3]; /* A A B */ STACK[TOP-3] = tmp; /* C A B */ }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,782
void js_rot3pop2(js_State *J) { /* A B C -> C */ STACK[TOP-3] = STACK[TOP-1]; TOP -= 2; }
Overflow
0
void js_rot3pop2(js_State *J) { /* A B C -> C */ STACK[TOP-3] = STACK[TOP-1]; TOP -= 2; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,783
void *js_savetry(js_State *J) { if (J->trytop == JS_TRYLIMIT) js_error(J, "try: exception stack overflow"); J->trybuf[J->trytop].E = J->E; J->trybuf[J->trytop].envtop = J->envtop; J->trybuf[J->trytop].tracetop = J->tracetop; J->trybuf[J->trytop].top = J->top; J->trybuf[J->trytop].bot = J->bot; J->trybuf[J->trytop].pc = NULL; return J->trybuf[J->trytop++].buf; }
Overflow
0
void *js_savetry(js_State *J) { if (J->trytop == JS_TRYLIMIT) js_error(J, "try: exception stack overflow"); J->trybuf[J->trytop].E = J->E; J->trybuf[J->trytop].envtop = J->envtop; J->trybuf[J->trytop].tracetop = J->tracetop; J->trybuf[J->trytop].top = J->top; J->trybuf[J->trytop].bot = J->bot; J->trybuf[J->trytop].pc = NULL; return J->trybuf[J->trytop++].buf; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,784
void *js_savetrypc(js_State *J, js_Instruction *pc) { if (J->trytop == JS_TRYLIMIT) js_error(J, "try: exception stack overflow"); J->trybuf[J->trytop].E = J->E; J->trybuf[J->trytop].envtop = J->envtop; J->trybuf[J->trytop].tracetop = J->tracetop; J->trybuf[J->trytop].top = J->top; J->trybuf[J->trytop].bot = J->bot; J->trybuf[J->trytop].pc = pc; return J->trybuf[J->trytop++].buf; }
Overflow
0
void *js_savetrypc(js_State *J, js_Instruction *pc) { if (J->trytop == JS_TRYLIMIT) js_error(J, "try: exception stack overflow"); J->trybuf[J->trytop].E = J->E; J->trybuf[J->trytop].envtop = J->envtop; J->trybuf[J->trytop].tracetop = J->tracetop; J->trybuf[J->trytop].top = J->top; J->trybuf[J->trytop].bot = J->bot; J->trybuf[J->trytop].pc = pc; return J->trybuf[J->trytop++].buf; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,785
void js_setglobal(js_State *J, const char *name) { jsR_setproperty(J, J->G, name); js_pop(J, 1); }
Overflow
0
void js_setglobal(js_State *J, const char *name) { jsR_setproperty(J, J->G, name); js_pop(J, 1); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,786
void js_setproperty(js_State *J, int idx, const char *name) { jsR_setproperty(J, js_toobject(J, idx), name); js_pop(J, 1); }
Overflow
0
void js_setproperty(js_State *J, int idx, const char *name) { jsR_setproperty(J, js_toobject(J, idx), name); js_pop(J, 1); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,787
void js_setregistry(js_State *J, const char *name) { jsR_setproperty(J, J->R, name); js_pop(J, 1); }
Overflow
0
void js_setregistry(js_State *J, const char *name) { jsR_setproperty(J, J->R, name); js_pop(J, 1); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,788
static void js_setvar(js_State *J, const char *name) { js_Environment *E = J->E; do { js_Property *ref = jsV_getproperty(J, E->variables, name); if (ref) { if (ref->setter) { js_pushobject(J, ref->setter); js_pushobject(J, E->variables); js_copy(J, -3); js_call(J, 1); js_pop(J, 1); return; } if (!(ref->atts & JS_READONLY)) ref->value = *stackidx(J, -1); else if (J->strict) js_typeerror(J, "'%s' is read-only", name); return; } E = E->outer; } while (E); if (J->strict) js_referenceerror(J, "assignment to undeclared variable '%s'", name); jsR_setproperty(J, J->G, name); }
Overflow
0
static void js_setvar(js_State *J, const char *name) { js_Environment *E = J->E; do { js_Property *ref = jsV_getproperty(J, E->variables, name); if (ref) { if (ref->setter) { js_pushobject(J, ref->setter); js_pushobject(J, E->variables); js_copy(J, -3); js_call(J, 1); js_pop(J, 1); return; } if (!(ref->atts & JS_READONLY)) ref->value = *stackidx(J, -1); else if (J->strict) js_typeerror(J, "'%s' is read-only", name); return; } E = E->outer; } while (E); if (J->strict) js_referenceerror(J, "assignment to undeclared variable '%s'", name); jsR_setproperty(J, J->G, name); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,789
static void js_stackoverflow(js_State *J) { STACK[TOP].type = JS_TLITSTR; STACK[TOP].u.litstr = "stack overflow"; ++TOP; js_throw(J); }
Overflow
0
static void js_stackoverflow(js_State *J) { STACK[TOP].type = JS_TLITSTR; STACK[TOP].u.litstr = "stack overflow"; ++TOP; js_throw(J); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,790
char *js_strdup(js_State *J, const char *s) { int n = strlen(s) + 1; char *p = js_malloc(J, n); memcpy(p, s, n); return p; }
Overflow
0
char *js_strdup(js_State *J, const char *s) { int n = strlen(s) + 1; char *p = js_malloc(J, n); memcpy(p, s, n); return p; }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,791
int js_toboolean(js_State *J, int idx) { return jsV_toboolean(J, stackidx(J, idx)); }
Overflow
0
int js_toboolean(js_State *J, int idx) { return jsV_toboolean(J, stackidx(J, idx)); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,792
short js_toint16(js_State *J, int idx) { return jsV_numbertoint16(jsV_tonumber(J, stackidx(J, idx))); }
Overflow
0
short js_toint16(js_State *J, int idx) { return jsV_numbertoint16(jsV_tonumber(J, stackidx(J, idx))); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,793
int js_toint32(js_State *J, int idx) { return jsV_numbertoint32(jsV_tonumber(J, stackidx(J, idx))); }
Overflow
0
int js_toint32(js_State *J, int idx) { return jsV_numbertoint32(jsV_tonumber(J, stackidx(J, idx))); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,794
int js_tointeger(js_State *J, int idx) { return jsV_numbertointeger(jsV_tonumber(J, stackidx(J, idx))); }
Overflow
0
int js_tointeger(js_State *J, int idx) { return jsV_numbertointeger(jsV_tonumber(J, stackidx(J, idx))); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,795
double js_tonumber(js_State *J, int idx) { return jsV_tonumber(J, stackidx(J, idx)); }
Overflow
0
double js_tonumber(js_State *J, int idx) { return jsV_tonumber(J, stackidx(J, idx)); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,796
js_Object *js_toobject(js_State *J, int idx) { return jsV_toobject(J, stackidx(J, idx)); }
Overflow
0
js_Object *js_toobject(js_State *J, int idx) { return jsV_toobject(J, stackidx(J, idx)); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,797
void js_toprimitive(js_State *J, int idx, int hint) { jsV_toprimitive(J, stackidx(J, idx), hint); }
Overflow
0
void js_toprimitive(js_State *J, int idx, int hint) { jsV_toprimitive(J, stackidx(J, idx), hint); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,798
const char *js_tostring(js_State *J, int idx) { return jsV_tostring(J, stackidx(J, idx)); }
Overflow
0
const char *js_tostring(js_State *J, int idx) { return jsV_tostring(J, stackidx(J, idx)); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null
10,799
unsigned short js_touint16(js_State *J, int idx) { return jsV_numbertouint16(jsV_tonumber(J, stackidx(J, idx))); }
Overflow
0
unsigned short js_touint16(js_State *J, int idx) { return jsV_numbertouint16(jsV_tonumber(J, stackidx(J, idx))); }
@@ -937,7 +937,7 @@ static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environmen jsR_savescope(J, scope); if (n > F->numparams) { - js_pop(J, F->numparams - n); + js_pop(J, n - F->numparams); n = F->numparams; } for (i = n; i < F->varlen; ++i)
CWE-119
null
null