# HG changeset patch # User Daniel Atallah # Date 1192294557 0 # Node ID 65c27d3383ea0b5cc4e10676251f221ae254e625 # Parent 74ec24deb267db777fdad43b96a89262545bb571 Prevent invalid data length from getting passed to fwrite. diff -r 74ec24deb267 -r 65c27d3383ea libpurple/util.c --- a/libpurple/util.c Sat Oct 13 16:36:06 2007 +0000 +++ b/libpurple/util.c Sat Oct 13 16:55:57 2007 +0000 @@ -2565,6 +2565,8 @@ purple_debug_info("util", "Writing file %s\n", filename_full); + g_return_val_if_fail((size >= 0 || size == -1), FALSE); + filename_temp = g_strdup_printf("%s.save", filename_full); /* Remove an old temporary file, if one exists */ @@ -2590,7 +2592,7 @@ } /* Write to file */ - real_size = (size == -1) ? strlen(data) : size; + real_size = (size == -1) ? strlen(data) : (size_t) size; byteswritten = fwrite(data, 1, real_size, file); /* Close file */