windows-printf-format-string-protection-20080108
authorJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 8 Jan 2008 06:27:36 +0000 (06:27 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 8 Jan 2008 06:27:36 +0000 (06:27 +0000)
LICENSE MIT

Do not pass strings generated from incoming network data to ??printf
as the format string.  Instead use a format string of "%s".  This protects
against %? expansions being inserted in the string.

src/WINNT/afsd/smb3.c

index ff3f03b..fbb0cc3 100644 (file)
@@ -168,7 +168,7 @@ void OutputDebugHexDump(unsigned char * buffer, int len) {
     for (i=0;i<len;i++) {
         if(!(i%16)) {
             if(i) {
-                osi_Log0(smb_logp, osi_LogSaveString(smb_logp, buf));
+                osi_Log0(smb_logp, "%s", osi_LogSaveString(smb_logp, buf));
                 strcat(buf,"\r\n");
                 OutputDebugString(buf);
             }
@@ -189,7 +189,7 @@ void OutputDebugHexDump(unsigned char * buffer, int len) {
         buf[j] = (k>32 && k<127)?k:'.';
     }    
     if(i) {
-        osi_Log0(smb_logp, osi_LogSaveString(smb_logp, buf));
+        osi_Log0(smb_logp, "%s", osi_LogSaveString(smb_logp, buf));
         strcat(buf,"\r\n");
         OutputDebugString(buf);
     }