]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
grub_cmd_play: Avoid division by zero.
authorVladimir Serbinenko <phcoder@gmail.com>
Tue, 20 Jan 2015 13:11:32 +0000 (14:11 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Wed, 21 Jan 2015 16:42:10 +0000 (17:42 +0100)
ChangeLog
grub-core/commands/i386/pc/play.c

index 14284774f50c7d640930ba2133a9dd862996b998..3ae00de22171a690f7881b997e2a27e40b3e50cc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-20  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/commands/i386/pc/play.c (grub_cmd_play): Avoid
+       division by zero.
+
 2015-01-20  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/bus/usb/usbtrans.c (grub_usb_bulk_maxpacket): Avoid
index 40798c96c8138830667d5c24ba71d00cb95afdbc..7712e2a36a17d3b052585de7a165d86e31b65a35 100644 (file)
@@ -107,6 +107,14 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
           return grub_errno;
         }
 
+      if (!tempo)
+        {
+          grub_file_close (file);
+         grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid tempo in %s"),
+                     args[0]);
+          return grub_errno;
+        }
+
       tempo = grub_le_to_cpu32 (tempo);
       grub_dprintf ("play","tempo = %d\n", tempo);
 
@@ -131,6 +139,13 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
 
       tempo = grub_strtoul (args[0], &end, 0);
 
+      if (!tempo)
+        {
+         grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid tempo in %s"),
+                     args[0]);
+          return grub_errno;
+        }
+
       if (*end)
         /* Was not a number either, assume it was supposed to be a file name.  */
         return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), args[0]);