libwebsockets - gcc warnings
authorPatrick McManus <mcmanus@ducksong.com>
Wed, 9 Mar 2011 07:18:28 +0000 (07:18 +0000)
committerAndy Green <andy.green@linaro.org>
Wed, 9 Mar 2011 07:18:28 +0000 (07:18 +0000)
you have your makefiles set up to treat warnings as errors, and my gcc
4.4.5 (64 bit) compiler generates 3 warnings that need fixing:

(that sprintf() one is a real bug.. if ext_name contains formatting
characters you are looking at a potential segv).

Signed-off-by: Patrick McManus <mcmanus@ducksong.com>
lib/handshake.c
lib/libwebsockets.c

index 7c8310f..e89bd01 100644 (file)
@@ -421,7 +421,7 @@ handshake_0405(struct libwebsocket *wsi)
                                
                                if (ext_count)
                                        *p++ = ',';
-                               p += sprintf(p, ext_name);
+                               p += sprintf(p, "%s", ext_name);
                                ext_count++;
 
                                /* instantiate the extension on this conn */
index 80d17de..9bb44b4 100644 (file)
@@ -1187,8 +1187,9 @@ libwebsocket_service_fd(struct libwebsocket_context *context,
                                        NULL, &p, (pkt + sizeof(pkt)) - p - 12);
 
                        p += sprintf(p, "\x0d\x0a");
-                       
-                       read(context->fd_random, p, 8);
+
+                       if (libwebsockets_get_random(context, p, 8) != 8)
+                               return -1;
                        memcpy(&challenge[8], p, 8);
                        p += 8;
                        
@@ -1242,7 +1243,7 @@ libwebsocket_service_fd(struct libwebsocket_context *context,
                        
                        if (ext_count)
                                *p++ = ',';
-                       p += sprintf(p, ext->name);
+                       p += sprintf(p, "%s", ext->name);
                        ext_count++;
 
                        ext++;