/*
*/
/*
*
*
* Software.
*
*/
message="Null pointer dereference in call to ", callee_name(), ". Pointer ", name(ptr), " may be dereferenced";
}
message="Unchecked return value from call to ", callee_name(), ". Value " , name(val), " must be checked to ensure this function was successful.";
}
message="Incorrect pointer size in call to ", callee_name(), ". Pointer ", name(ptr), " given as size ", size;
}
/*************************************************************************
*/
/** libX11 **/
}
}
}
}
"null-pointer-deref-call-X"(p) : p != 0;
}
}
}
"null-pointer-deref-call-X"(d) : d != 0;
"null-pointer-deref-call-X"(n) : n != 0;
}
}
"null-pointer-deref-call-X"(d) : d != 0;
}
}
"null-pointer-deref-call-X"(d) : d != 0;
result != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
result != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
result != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
result != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
result != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
result != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
} else {
@errno != 0;
}
}
"null-pointer-deref-call-X"(d) : d != 0;
result != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
} else {
@errno != 0;
}
}
"null-pointer-deref-call-X"(d) : d != 0;
} else {
@errno != 0;
}
}
"null-pointer-deref-call-X"(d) : d != 0;
result != 0;
}
/* Todo: XGetSelectionOwner */
"null-pointer-deref-call-X"(d) : d != 0;
result != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
"null-pointer-deref-call-X"(n) : n != 0;
}
}
"null-pointer-deref-call-X"(d) : d != 0;
}
}
"null-pointer-deref-call-X"(d) : d != 0;
}
}
"null-pointer-deref-call-X"(d) : d != 0;
}
"null-pointer-deref-call-X"(e) : e != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
}
}
"null-pointer-deref-call-X"(s) : s != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
}
"null-pointer-deref-call-X"(s) : s != 0;
}
"null-pointer-deref-call-X"(v) : v != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
}
}
"null-pointer-deref-call-X"(s) : s != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
"null-pointer-deref-call-X"(c) : c != 0;
} else {
@errno != 0;
}
}
"null-pointer-deref-call-X"(d) : d != 0;
"null-pointer-deref-call-X"(c) : c != 0;
} else {
@errno != 0;
}
}
"null-pointer-deref-call-X"(d) : d != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
"null-pointer-deref-call-X"(h) : h != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
"null-pointer-deref-call-X"(h) : h != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
min >= 8;
max <= 255;
}
"null-pointer-deref-call-X"(d) : d != 0;
result == 1;
}
}
"null-pointer-deref-call-X"(d) : d != 0;
}
/* Todo: XFreeColors */
"null-pointer-deref-call-X"(d) : d != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
}
}
"null-pointer-deref-call-X"(d) : d != 0;
}
"null-pointer-deref-call-X"(d) : d != 0;
}
/* Todo: XGeometry...XGetGeometry */
"null-pointer-deref-call-X"(d) : d != 0;
}
result == 0;
}
}
"null-pointer-deref-call-X"(d) : d != 0;
op >= 128;
op <= 255;
}
}
"null-pointer-deref-call-X"(d) : d != 0;
"null-pointer-deref-call-X"(c) : c != 0;
}
}
/** libXt
* instead of return NULL
*/
XtAsprintf(p,const fmt,args...) : printf(fmt,args), noescape {
*p == new(result + 1);
strlen(*p) == result;
may_write(*p);
}
XtMalloc(s) {
result == new(s);
}
XtRealloc(p,s) {
delete(p);
result == new(s);
result[0..(size(PRE p) < s ? size(PRE p) : s)] == PRE p[0..(size(PRE p) < s ? size(PRE p) : s)];
}
XtCalloc(n,s) {
result == new(n*s);
result[0 .. (n * s)] == bytes(0, (n * s));
}
XtFree(p) : free(p);
/* libXcursor private function */
XcursorScanTheme(theme, name) : noescape {
(theme == 0 || name == 0) => result == 0;
(result != 0 && result != 1) => init<file-ptr>(result);
}
/*************************************************************************
* Server side functions
*/
/* XXX - does not work! */
bugtype "wrong-size-swap"(ptr,funcsize) {
name="Wrong size Xserver swap function used";
priority="error";
enabled="true";
message="Wrong size swap function used: ", callee_name(), " expects ", funcsize, "-byte variable, got ", size(ptr),"-byte ", name(ptr), " instead.";
}
swap_uint32(x) : noescape {
"wrong-size-swap"(x,4): size(*x) == 4;
}
swap_uint16(x) : noescape {
"wrong-size-swap"(x,2): size(*x) == 4;
}
SwapLongs(x,count) : noescape {
"wrong-size-swap"(x,4): size(x) == 4;
}
SwapShorts(x,count) : noescape {
"wrong-size-swap"(x,2): size(x) == 4;
}
MakeAtom(string, len, makeit) : noescape {
"null-pointer-deref-call-X"(string): string != 0;
"buffer-overflow-call-stdc-str"(string): len <= strlen(string);
}
LogWrite(verb, const fmt, args...) : printf(fmt, args), noescape;
LogMessageVerb(type, verb, const fmt, args...) : printf(fmt, args), noescape;
LogMessage(type, const fmt, args...) : printf(fmt, args), noescape;
FatalError(const fmt, args...) : printf(fmt, args), noescape, exit;
ErrorF(const fmt, args...) : printf(fmt, args), noescape;
AbortServer(): exit;
Xalloc(s) : malloc(s);
XNFalloc(s) {
result == new(s);
}
Xcalloc(s) : calloc(1,s);
XNFcalloc(s) {
result == new(s);
result[0 .. s] == bytes(0, s);
}
Xrealloc(p, s) : realloc(p, s);
XNFrealloc(p, s) : realloc(p, s);
Xfree(p) : free(p);
Xstrdup(const s) : noescape {
if ( s == 0 ) {
result == 0;
} else {
if ( result != 0 ) {
result == new(strlen(s)+1);
strlen(result) == strlen(s);
}
}
}
XNFstrdup(const s) : noescape {
if ( s == 0 ) {
result == 0;
} else {
result == new(strlen(s)+1);
strlen(result) == strlen(s);
}
}
OsAbort() : abort();
Fopen(f, m) : fopen(f, m);
Fclose(p) : fclose(p);
Xvasprintf(p, fmt, va) : vasprintf(p, fmt, va);
Xasprintf(p, fmt, args...) : asprintf(p, fmt, args);
XNFvasprintf(p, fmt, va) : noescape {
*p == new(result);
may_write(*p);
}
XNFasprintf(p, fmt, args...) : noescape, printf(fmt, args) {
*p == new(result);
may_write(*p);
}
Xvprintf(fmt, va) : noescape {
if (result != 0) {
result == new(undefined);
may_write(result);
}
}
Xprintf(fmt, args...) : noescape, printf(fmt, args) {
if (result != 0) {
result == new(undefined);
may_write(result);
}
}
XNFvprintf(fmt, va) : noescape {
result == new(undefined);
may_write(result);
}
XNFprintf(fmt, args...) : noescape, printf(fmt, args) {
result == new(undefined);
may_write(result);
}
/*************************************************************************
* Kernel modules
*/
@if (file=="kernel/*") {
/* graphics driver porting layer: open-src/kernel/drm/src/drm_memory.c */
drm_alloc(s, a) : calloc(1, s);
drm_calloc(n, s, a) : calloc(n, s);
drm_realloc(pp, ps, s, a) : realloc(pp, s) {
"pointer-size-mismatch-kernel"(pp,ps) : ps == size(pp);
}
"pointer-size-mismatch-kernel"(p,s) : s == size(p);
delete(p);
}
}