[PATCH:libFS 2/2] Off-by-one error on the other end of FSGetErrorText bounds check

Alan Coopersmith alan.coopersmith at oracle.com
Sun Feb 13 10:45:06 PST 2011


The Font Server protocol actually defines 0 as an error code too.

Before this fix, test/FSGetErrorText printed:

FSGetErrorText for code FSBadRequest (0) returned:
||

Afterwards:

FSGetErrorText for code FSBadRequest (0) returned:
|BadRequest, invalid request code or no such operation|

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 src/FSErrDis.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/FSErrDis.c b/src/FSErrDis.c
index 5e9d9d2..5c1188f 100644
--- a/src/FSErrDis.c
+++ b/src/FSErrDis.c
@@ -104,7 +104,7 @@ int FSGetErrorText(
     if (nbytes == 0)
 	return 0;
     snprintf(buf, sizeof(buf), "%d", code);
-    if (code < (FSErrorListSize / sizeof(char *)) && code > 0) {
+    if (code < (FSErrorListSize / sizeof(char *)) && code >= 0) {
 	defaultp = FSErrorList[code];
 	FSGetErrorDatabaseText(svr, "FSProtoError", buf, defaultp, buffer, nbytes);
     }
-- 
1.7.3.2



More information about the xorg-devel mailing list